Commit a17ea35793518cb0a4b7f71abbbdfbf78da4138c
1 parent
35c016d0
ini
Showing
46 changed files
with
4740 additions
and
0 deletions
Too many changes to show.
To preserve performance only 46 of 348 files are displayed.
titan-api/pom.xml
0 → 100755
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 | + | ||
6 | +<groupId>com.dili</groupId> | ||
7 | + <artifactId>titan-api</artifactId> | ||
8 | + <packaging>war</packaging> | ||
9 | + <name>titan-api-web</name> | ||
10 | +<properties> | ||
11 | + <jdk.version>1.7</jdk.version> | ||
12 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
13 | + <maven.compiler.encoding>UTF-8</maven.compiler.encoding> | ||
14 | + <spring.version>3.2.9.RELEASE</spring.version> | ||
15 | + <aspectj.version>1.6.11</aspectj.version> | ||
16 | + <jackson.version>1.9.2</jackson.version> | ||
17 | + <slf4j.version>1.6.4</slf4j.version> | ||
18 | + </properties> | ||
19 | + | ||
20 | + <!-- 插件管理 --> | ||
21 | + <build> | ||
22 | + <finalName>titan-api-web</finalName> | ||
23 | + <resources> | ||
24 | + <resource> | ||
25 | + <directory>${project.basedir}/src/main/resources</directory> | ||
26 | + <filtering>true</filtering> | ||
27 | + </resource> | ||
28 | + </resources> | ||
29 | + <pluginManagement> | ||
30 | + <plugins> | ||
31 | + <plugin> | ||
32 | + <!-- war插件 --> | ||
33 | + <groupId>org.apache.maven.plugins</groupId> | ||
34 | + <artifactId>maven-war-plugin</artifactId> | ||
35 | + <version>2.3</version> | ||
36 | + </plugin> | ||
37 | + <plugin> | ||
38 | + <groupId>org.apache.maven.plugins</groupId> | ||
39 | + <artifactId>maven-compiler-plugin</artifactId> | ||
40 | + <version>2.5.1</version> | ||
41 | + <configuration> | ||
42 | + <source>1.7</source> | ||
43 | + <target>1.7</target> | ||
44 | + <encoding>UTF-8</encoding> | ||
45 | + </configuration> | ||
46 | + </plugin> | ||
47 | + <!-- 配置构建时忽略测试用例 --> | ||
48 | + <plugin> | ||
49 | + <groupId>org.apache.maven.plugins</groupId> | ||
50 | + <artifactId>maven-surefire-plugin</artifactId> | ||
51 | + <configuration> | ||
52 | + <skipTests>true</skipTests> | ||
53 | + </configuration> | ||
54 | + </plugin> | ||
55 | + <plugin> | ||
56 | + <groupId>org.mortbay.jetty</groupId> | ||
57 | + <artifactId>maven-jetty-plugin</artifactId> | ||
58 | + <version>6.1.26</version> | ||
59 | + <configuration> | ||
60 | + <scanIntervalSeconds>3</scanIntervalSeconds> | ||
61 | + <contextPath>/</contextPath> | ||
62 | + <connectors> | ||
63 | + <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> | ||
64 | + <port>80</port> | ||
65 | + </connector> | ||
66 | + </connectors> | ||
67 | + </configuration> | ||
68 | + </plugin> | ||
69 | + <plugin> | ||
70 | + <groupId>org.apache.tomcat.maven</groupId> | ||
71 | + <artifactId>tomcat7-maven-plugin</artifactId> | ||
72 | + <version>2.2</version> | ||
73 | + <configuration> | ||
74 | + <port>80</port> | ||
75 | + <path>/</path> | ||
76 | + </configuration> | ||
77 | + </plugin> | ||
78 | + <plugin> | ||
79 | + <artifactId>maven-resources-plugin</artifactId> | ||
80 | + <version>2.5</version> | ||
81 | + <executions> | ||
82 | + <execution> | ||
83 | + <id>copy-xmls</id> | ||
84 | + <phase>process-sources</phase> | ||
85 | + <goals> | ||
86 | + <goal>copy-resources</goal> | ||
87 | + </goals> | ||
88 | + <configuration> | ||
89 | + <outputDirectory>${basedir}/target/classes</outputDirectory> | ||
90 | + <resources> | ||
91 | + <resource> | ||
92 | + <directory>${basedir}/src/main/hbase-profiles/${package.env}</directory> | ||
93 | + <includes> | ||
94 | + <include>**/*.xml</include> | ||
95 | + </includes> | ||
96 | + </resource> | ||
97 | + </resources> | ||
98 | + </configuration> | ||
99 | + </execution> | ||
100 | + </executions> | ||
101 | + </plugin> | ||
102 | + </plugins> | ||
103 | + </pluginManagement> | ||
104 | + </build> | ||
105 | + | ||
106 | + <dependencies> | ||
107 | + <!-- spring --> | ||
108 | + <dependency> | ||
109 | + <groupId>org.springframework</groupId> | ||
110 | + <artifactId>spring-webmvc</artifactId> | ||
111 | + <version>${spring.version}</version> | ||
112 | + <exclusions> | ||
113 | + <exclusion> | ||
114 | + <groupId>commons-logging</groupId> | ||
115 | + <artifactId>commons-logging</artifactId> | ||
116 | + </exclusion> | ||
117 | + </exclusions> | ||
118 | + </dependency> | ||
119 | + <dependency> | ||
120 | + <groupId>org.springframework</groupId> | ||
121 | + <artifactId>spring-jdbc</artifactId> | ||
122 | + <version>${spring.version}</version> | ||
123 | + </dependency> | ||
124 | + <dependency> | ||
125 | + <groupId>org.springframework</groupId> | ||
126 | + <artifactId>spring-tx</artifactId> | ||
127 | + <version>${spring.version}</version> | ||
128 | + </dependency> | ||
129 | + <dependency> | ||
130 | + <groupId>org.springframework</groupId> | ||
131 | + <artifactId>spring-asm</artifactId> | ||
132 | + <version>${spring.version}</version> | ||
133 | + </dependency> | ||
134 | + <dependency> | ||
135 | + <groupId>org.springframework</groupId> | ||
136 | + <artifactId>spring-context-support</artifactId> | ||
137 | + <version>${spring.version}</version> | ||
138 | + </dependency> | ||
139 | + <dependency> | ||
140 | + <groupId>org.springframework</groupId> | ||
141 | + <artifactId>spring-expression</artifactId> | ||
142 | + <version>${spring.version}</version> | ||
143 | + </dependency> | ||
144 | + <dependency> | ||
145 | + <groupId>org.springframework</groupId> | ||
146 | + <artifactId>spring-web</artifactId> | ||
147 | + <version>${spring.version}</version> | ||
148 | + </dependency> | ||
149 | + | ||
150 | + <!-- LOG4J日志记录 --> | ||
151 | + <dependency> | ||
152 | + <groupId>org.slf4j</groupId> | ||
153 | + <artifactId>slf4j-api</artifactId> | ||
154 | + <version>1.6.4</version> | ||
155 | + </dependency> | ||
156 | + <dependency> | ||
157 | + <groupId>org.slf4j</groupId> | ||
158 | + <artifactId>slf4j-log4j12</artifactId> | ||
159 | + <version>1.6.4</version> | ||
160 | + </dependency> | ||
161 | + <dependency> | ||
162 | + <groupId>log4j</groupId> | ||
163 | + <artifactId>log4j</artifactId> | ||
164 | + <version>1.2.17</version> | ||
165 | + </dependency> | ||
166 | + | ||
167 | + <dependency> | ||
168 | + <groupId>commons-lang</groupId> | ||
169 | + <artifactId>commons-lang</artifactId> | ||
170 | + <version>2.5</version> | ||
171 | + </dependency> | ||
172 | + | ||
173 | + <dependency> | ||
174 | + <groupId>commons-codec</groupId> | ||
175 | + <artifactId>commons-codec</artifactId> | ||
176 | + <version>1.2</version> | ||
177 | + </dependency> | ||
178 | + <dependency> | ||
179 | + <groupId>org.mybatis</groupId> | ||
180 | + <artifactId>mybatis</artifactId> | ||
181 | + <version>3.2.1</version> | ||
182 | + </dependency> | ||
183 | + <dependency> | ||
184 | + <groupId>org.mybatis</groupId> | ||
185 | + <artifactId>mybatis-spring</artifactId> | ||
186 | + <version>1.2.0</version> | ||
187 | + </dependency> | ||
188 | + <dependency> | ||
189 | + <groupId>com.alibaba</groupId> | ||
190 | + <artifactId>druid</artifactId> | ||
191 | + <version>1.0.11</version> | ||
192 | + </dependency> | ||
193 | + <dependency> | ||
194 | + <groupId>mysql</groupId> | ||
195 | + <artifactId>mysql-connector-java</artifactId> | ||
196 | + <version>5.1.25</version> | ||
197 | + </dependency> | ||
198 | + | ||
199 | + <!-- 工具类 --> | ||
200 | + <!-- google sets,maps --> | ||
201 | + <!--<dependency>--> | ||
202 | + <!--<groupId>com.google.guava</groupId>--> | ||
203 | + <!--<artifactId>guava</artifactId>--> | ||
204 | + <!--<version>14.0.1</version>--> | ||
205 | + <!--</dependency>--> | ||
206 | + <!-- JSON --> | ||
207 | + <dependency> | ||
208 | + <groupId>com.alibaba</groupId> | ||
209 | + <artifactId>fastjson</artifactId> | ||
210 | + <version>1.1.31</version> | ||
211 | + </dependency> | ||
212 | + <dependency> | ||
213 | + <groupId>org.aspectj</groupId> | ||
214 | + <artifactId>aspectjweaver</artifactId> | ||
215 | + <version>1.7.2</version> | ||
216 | + </dependency> | ||
217 | + <!--<dependency>--> | ||
218 | + <!--<groupId>cglib</groupId>--> | ||
219 | + <!--<artifactId>cglib-nodep</artifactId>--> | ||
220 | + <!--<version>2.1_3</version>--> | ||
221 | + <!--</dependency>--> | ||
222 | + | ||
223 | + <!-- common logging replacer --> | ||
224 | + <dependency> | ||
225 | + <groupId>org.slf4j</groupId> | ||
226 | + <artifactId>jcl-over-slf4j</artifactId> | ||
227 | + <version>${slf4j.version}</version> | ||
228 | + </dependency> | ||
229 | + <!-- if you enable @AspectJ style AOP in spring. --> | ||
230 | + <dependency> | ||
231 | + <groupId>org.aspectj</groupId> | ||
232 | + <artifactId>aspectjrt</artifactId> | ||
233 | + <version>${aspectj.version}</version> | ||
234 | + </dependency> | ||
235 | + <!-- if you enable JSR303 (Bean Validation) in spring. --> | ||
236 | + <!--<dependency>--> | ||
237 | + <!--<groupId>org.hibernate</groupId>--> | ||
238 | + <!--<artifactId>hibernate-validator</artifactId>--> | ||
239 | + <!--<version>4.2.0.Final</version>--> | ||
240 | + <!--</dependency>--> | ||
241 | + <!-- if you use velocity view in springmvc --> | ||
242 | + <dependency> | ||
243 | + <groupId>org.apache.velocity</groupId> | ||
244 | + <artifactId>velocity</artifactId> | ||
245 | + <version>1.7</version> | ||
246 | + </dependency> | ||
247 | + <!-- if you use velocity layout view in springmvc --> | ||
248 | + <dependency> | ||
249 | + <groupId>org.apache.velocity</groupId> | ||
250 | + <artifactId>velocity-tools</artifactId> | ||
251 | + <version>2.0</version> | ||
252 | + <exclusions> | ||
253 | + <exclusion> | ||
254 | + <groupId>org.apache.struts</groupId> | ||
255 | + <artifactId>struts-core</artifactId> | ||
256 | + </exclusion> | ||
257 | + <exclusion> | ||
258 | + <groupId>org.apache.struts</groupId> | ||
259 | + <artifactId>struts-taglib</artifactId> | ||
260 | + </exclusion> | ||
261 | + <exclusion> | ||
262 | + <groupId>org.apache.struts</groupId> | ||
263 | + <artifactId>struts-tiles</artifactId> | ||
264 | + </exclusion> | ||
265 | + <exclusion> | ||
266 | + <groupId>sslext</groupId> | ||
267 | + <artifactId>sslext</artifactId> | ||
268 | + </exclusion> | ||
269 | + </exclusions> | ||
270 | + </dependency> | ||
271 | + <!-- if you enable json support in spring mvc. --> | ||
272 | + <dependency> | ||
273 | + <groupId>org.codehaus.jackson</groupId> | ||
274 | + <artifactId>jackson-mapper-asl</artifactId> | ||
275 | + <version>${jackson.version}</version> | ||
276 | + </dependency> | ||
277 | + <!-- test scope --> | ||
278 | + <dependency> | ||
279 | + <groupId>junit</groupId> | ||
280 | + <artifactId>junit</artifactId> | ||
281 | + <version>4.10</version> | ||
282 | + <scope>test</scope> | ||
283 | + </dependency> | ||
284 | + <dependency> | ||
285 | + <groupId>javax.servlet</groupId> | ||
286 | + <artifactId>servlet-api</artifactId> | ||
287 | + <version>2.4</version> | ||
288 | + <scope>provided</scope> | ||
289 | + </dependency> | ||
290 | + | ||
291 | + <dependency> | ||
292 | + <groupId>redis.clients</groupId> | ||
293 | + <artifactId>jedis</artifactId> | ||
294 | + <version>2.4.2</version> | ||
295 | + </dependency> | ||
296 | + <dependency> | ||
297 | + <groupId>org.springframework.data</groupId> | ||
298 | + <artifactId>spring-data-redis</artifactId> | ||
299 | + <version>1.3.0.RELEASE</version> | ||
300 | + <exclusions> | ||
301 | + <exclusion> | ||
302 | + <groupId>org.springframework</groupId> | ||
303 | + <artifactId>spring-core</artifactId> | ||
304 | + </exclusion> | ||
305 | + <exclusion> | ||
306 | + <groupId>org.springframework</groupId> | ||
307 | + <artifactId>spring-aop</artifactId> | ||
308 | + </exclusion> | ||
309 | + <exclusion> | ||
310 | + <groupId>org.springframework</groupId> | ||
311 | + <artifactId>spring-context</artifactId> | ||
312 | + </exclusion> | ||
313 | + </exclusions> | ||
314 | + </dependency> | ||
315 | + <dependency> | ||
316 | + <artifactId>hbase-client</artifactId> | ||
317 | + <groupId>org.apache.hbase</groupId> | ||
318 | + <version>0.96.1.1-cdh5.0.0</version> | ||
319 | + </dependency> | ||
320 | + <dependency> | ||
321 | + <groupId>org.springframework</groupId> | ||
322 | + <artifactId>spring-test</artifactId> | ||
323 | + <version>${spring.version}</version> | ||
324 | + </dependency> | ||
325 | + <dependency> | ||
326 | + <groupId>org.apache.httpcomponents</groupId> | ||
327 | + <artifactId>httpclient</artifactId> | ||
328 | + <version>4.3.3</version> | ||
329 | + </dependency> | ||
330 | + <dependency> | ||
331 | + <groupId>net.bull.javamelody</groupId> | ||
332 | + <artifactId>javamelody-core</artifactId> | ||
333 | + <version>1.37.0</version> | ||
334 | + </dependency> | ||
335 | + | ||
336 | + <dependency> | ||
337 | + <groupId>commons-fileupload</groupId> | ||
338 | + <artifactId>commons-fileupload</artifactId> | ||
339 | + <version>1.3</version> | ||
340 | + </dependency> | ||
341 | + <!--监控平台接入 --> | ||
342 | + <dependency> | ||
343 | + <groupId>com.dili.dd.monitor</groupId> | ||
344 | + <artifactId>monitor</artifactId> | ||
345 | + <version>0.0.3-SNAPSHOT</version> | ||
346 | + </dependency> | ||
347 | + </dependencies> | ||
348 | + | ||
349 | + <!-- 打包配置信息 --> | ||
350 | + <profiles> | ||
351 | + <profile> | ||
352 | + <!-- 开发环境 --> | ||
353 | + <id>develop</id> | ||
354 | + <!-- 默认 --> | ||
355 | + <activation> | ||
356 | + <activeByDefault>true</activeByDefault> | ||
357 | + </activation> | ||
358 | + <properties> | ||
359 | + <package.env>develop</package.env> | ||
360 | + <!--jdbc type --> | ||
361 | + <dili_titan.jdbc.datasource.type>dbcp</dili_titan.jdbc.datasource.type> | ||
362 | + <!-- 数据库 --> | ||
363 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | ||
364 | + <!-- 主库配置 --> | ||
365 | + <dili_titan.master.jdbc.url>jdbc:MySql://10.28.10.188:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | ||
366 | + <dili_titan.master.jdbc.username>root</dili_titan.master.jdbc.username> | ||
367 | + <dili_titan.master.jdbc.password>123456</dili_titan.master.jdbc.password> | ||
368 | + <!-- 从库配置 --> | ||
369 | + <dili_titan.slave.jdbc.url>jdbc:MySql://10.28.10.188:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | ||
370 | + <dili_titan.slave.jdbc.username>du</dili_titan.slave.jdbc.username> | ||
371 | + <dili_titan.slave.jdbc.password>123456</dili_titan.slave.jdbc.password> | ||
372 | + <!-- crm接口地址 --> | ||
373 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | ||
374 | + <!-- user接口地址 --> | ||
375 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | ||
376 | + <!--关键字接口地址--> | ||
377 | + <dili_titan.keywords.url>keyword.filter.1n4j.com</dili_titan.keywords.url> | ||
378 | + <!--shop接口地址,需要测试自己修改 --> | ||
379 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | ||
380 | + <!-- redis接口地址 --> | ||
381 | + <dili_titan.redis.url>10.28.10.208</dili_titan.redis.url> | ||
382 | + <!--权限管理的redis配置--> | ||
383 | + <manage.redis.url>10.28.10.208</manage.redis.url> | ||
384 | + <manage.redis.port>6379</manage.redis.port> | ||
385 | + <!-- MQ 地址--> | ||
386 | + <conf.mq.namesrvAddr>10.28.10.209:9876;10.28.10.149:9876</conf.mq.namesrvAddr> | ||
387 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | ||
388 | + <!-- website接口地址 --> | ||
389 | + <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | ||
390 | + <!-- 日志 --> | ||
391 | + <dili_titan.log.level>INFO</dili_titan.log.level> | ||
392 | + <dili_titan.log.path>/export/logs</dili_titan.log.path> | ||
393 | + <dili_titan.log.root.appender>CONSOLE</dili_titan.log.root.appender> | ||
394 | + <!--打包编码 --> | ||
395 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
396 | + <!-- 图片服务器前缀 --> | ||
397 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | ||
398 | + <!--爱奇艺视频 --> | ||
399 | + <titan.aqy.appkey>e64a09bece964bb484e5decc30c0b950</titan.aqy.appkey> | ||
400 | + <titan.aqy.appSecret>f48d2b799f9661acdb6041e4ac7c142f</titan.aqy.appSecret> | ||
401 | + </properties> | ||
402 | + </profile> | ||
403 | + <profile> | ||
404 | + <!-- 测试环境 --> | ||
405 | + <id>test</id> | ||
406 | + <activation> | ||
407 | + <activeByDefault>false</activeByDefault> | ||
408 | + </activation> | ||
409 | + <properties> | ||
410 | + <package.env>test</package.env> | ||
411 | + <!--jdbc type --> | ||
412 | + <dili_titan.jdbc.datasource.type>dbcp</dili_titan.jdbc.datasource.type> | ||
413 | + <!-- 数据库 --> | ||
414 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | ||
415 | + <!-- 主库配置 --> | ||
416 | + <dili_titan.master.jdbc.url>jdbc:MySql://10.28.6.156:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | ||
417 | + <dili_titan.master.jdbc.username>root</dili_titan.master.jdbc.username> | ||
418 | + <dili_titan.master.jdbc.password>123456</dili_titan.master.jdbc.password> | ||
419 | + <!-- 从库配置 --> | ||
420 | + <dili_titan.slave.jdbc.url>jdbc:MySql://10.28.6.155:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | ||
421 | + <dili_titan.slave.jdbc.username>agriez_titan_reader</dili_titan.slave.jdbc.username> | ||
422 | + <dili_titan.slave.jdbc.password>123456</dili_titan.slave.jdbc.password> | ||
423 | + <!-- crm接口地址 --> | ||
424 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | ||
425 | + <!-- user接口地址,需要测试自己修改 --> | ||
426 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | ||
427 | + <!--关键字接口地址--> | ||
428 | + <dili_titan.keywords.url>keyword.filter.1n4j.com</dili_titan.keywords.url> | ||
429 | + <!--shop接口地址,需要测试自己修改 --> | ||
430 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | ||
431 | + <!-- redis接口地址 --> | ||
432 | + <dili_titan.redis.url>10.28.10.207</dili_titan.redis.url> | ||
433 | + <!--权限管理的redis配置--> | ||
434 | + <manage.redis.url>10.28.10.207</manage.redis.url> | ||
435 | + <manage.redis.port>6379</manage.redis.port> | ||
436 | + <!-- MQ 地址--> | ||
437 | + <conf.mq.namesrvAddr>10.28.10.230:9876</conf.mq.namesrvAddr> | ||
438 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | ||
439 | + <!-- website接口地址 --> | ||
440 | + <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | ||
441 | + <!-- 日志 --> | ||
442 | + <dili_titan.log.level>INFO</dili_titan.log.level> | ||
443 | + <dili_titan.log.path>/home/tomcat/export</dili_titan.log.path> | ||
444 | + <dili_titan.log.root.appender>CONSOLE</dili_titan.log.root.appender> | ||
445 | + <!--打包编码 --> | ||
446 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
447 | + <!-- 图片服务器前缀 --> | ||
448 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | ||
449 | + <!--爱奇艺视频 --> | ||
450 | + <titan.aqy.appkey>e64a09bece964bb484e5decc30c0b950</titan.aqy.appkey> | ||
451 | + <titan.aqy.appSecret>f48d2b799f9661acdb6041e4ac7c142f</titan.aqy.appSecret> | ||
452 | + </properties> | ||
453 | + </profile> | ||
454 | + | ||
455 | + <profile> | ||
456 | + <!--预发布环境--> | ||
457 | + <id>pre-online</id> | ||
458 | + <!-- 默认 --> | ||
459 | + <activation> | ||
460 | + <activeByDefault>false</activeByDefault> | ||
461 | + </activation> | ||
462 | + <properties> | ||
463 | + <package.env>pre-online</package.env> | ||
464 | + | ||
465 | + <!--jdbc type --> | ||
466 | + <dili_titan.jdbc.datasource.type>dbcp</dili_titan.jdbc.datasource.type> | ||
467 | + <!-- 数据库 --> | ||
468 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | ||
469 | + <!-- 主库配置 --> | ||
470 | + <dili_titan.master.jdbc.url>jdbc:MySql://titan.db.1n4j.com:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | ||
471 | + <dili_titan.master.jdbc.username>root</dili_titan.master.jdbc.username> | ||
472 | + <dili_titan.master.jdbc.password>123456</dili_titan.master.jdbc.password> | ||
473 | + <!-- 从库配置 --> | ||
474 | + <dili_titan.slave.jdbc.url>jdbc:MySql://titan.db.1n4j.com:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | ||
475 | + <dili_titan.slave.jdbc.username>root</dili_titan.slave.jdbc.username> | ||
476 | + <dili_titan.slave.jdbc.password>123456</dili_titan.slave.jdbc.password> | ||
477 | + <!-- crm接口地址 --> | ||
478 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | ||
479 | + <!-- user接口地址 --> | ||
480 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | ||
481 | + <!--关键字接口地址--> | ||
482 | + <dili_titan.keywords.url>keyword.filter.1n4j.com</dili_titan.keywords.url> | ||
483 | + <!--shop接口地址,需要测试自己修改 --> | ||
484 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | ||
485 | + <!-- redis接口地址 --> | ||
486 | + <dili_titan.redis.url>redis.1n4j.com</dili_titan.redis.url> | ||
487 | + <!--权限管理的redis配置--> | ||
488 | + <manage.redis.url>redis.1n4j.com</manage.redis.url> | ||
489 | + <manage.redis.port>6379</manage.redis.port> | ||
490 | + <!-- MQ 地址--> | ||
491 | + <conf.mq.namesrvAddr>10.28.6.51:9876</conf.mq.namesrvAddr> | ||
492 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | ||
493 | + <!-- website接口地址 --> | ||
494 | + <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | ||
495 | + <!-- 日志 --> | ||
496 | + <dili_titan.log.level>INFO</dili_titan.log.level> | ||
497 | + <dili_titan.log.path>/diliapp/servers/logs</dili_titan.log.path> | ||
498 | + <dili_titan.log.root.appender>FILE_ALL</dili_titan.log.root.appender> | ||
499 | + <!--打包编码 --> | ||
500 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
501 | + <!-- 图片服务器前缀 --> | ||
502 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | ||
503 | + <!--爱奇艺视频 --> | ||
504 | + <titan.aqy.appkey>f689d13d9dce48039cae27e6e03940c6</titan.aqy.appkey> | ||
505 | + <titan.aqy.appSecret>8633dfebb9f4443d0f1244262bca94f6</titan.aqy.appSecret> | ||
506 | + </properties> | ||
507 | + </profile> | ||
508 | + | ||
509 | + <profile> | ||
510 | + <!--上线环境--> | ||
511 | + <id>online</id> | ||
512 | + <!-- 默认 --> | ||
513 | + <activation> | ||
514 | + <activeByDefault>false</activeByDefault> | ||
515 | + </activation> | ||
516 | + <properties> | ||
517 | + <package.env>online</package.env> | ||
518 | + <!--jdbc type --> | ||
519 | + <dili_titan.jdbc.datasource.type>dbcp</dili_titan.jdbc.datasource.type> | ||
520 | + <!-- 数据库 --> | ||
521 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | ||
522 | + <!-- 主库配置 --> | ||
523 | + <dili_titan.master.jdbc.url>jdbc:MySql://titan.db.1n4j.com:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | ||
524 | + <dili_titan.master.jdbc.username>appAccPayor</dili_titan.master.jdbc.username> | ||
525 | + <dili_titan.master.jdbc.password>iTDYVBtI6MX4NQ3Er2Oh</dili_titan.master.jdbc.password> | ||
526 | + <!-- 从库配置 --> | ||
527 | + <dili_titan.slave.jdbc.url>jdbc:MySql://192.168.60.61:3306/agriez_titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | ||
528 | + <dili_titan.slave.jdbc.username>appAccPayor</dili_titan.slave.jdbc.username> | ||
529 | + <dili_titan.slave.jdbc.password>iTDYVBtI6MX4NQ3Er2Oh</dili_titan.slave.jdbc.password> | ||
530 | + <!-- crm接口地址 --> | ||
531 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | ||
532 | + <!-- user接口地址 --> | ||
533 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | ||
534 | + <!--关键字接口地址--> | ||
535 | + <dili_titan.keywords.url>keyword.filter.1n4j.com</dili_titan.keywords.url> | ||
536 | + <!--shop接口地址,需要测试自己修改 --> | ||
537 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | ||
538 | + <!-- redis接口地址 --> | ||
539 | + <dili_titan.redis.url>redis.1n4j.com</dili_titan.redis.url> | ||
540 | + <!--权限管理的redis配置--> | ||
541 | + <manage.redis.url>redis.1n4j.com</manage.redis.url> | ||
542 | + <manage.redis.port>6379</manage.redis.port> | ||
543 | + <!-- MQ 地址--> | ||
544 | + <conf.mq.namesrvAddr>192.168.60.62:9876;192.168.60.63:9876</conf.mq.namesrvAddr> | ||
545 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | ||
546 | + <!-- website接口地址 --> | ||
547 | + <dili_titan.website.url>manweb.1n4j.com</dili_titan.website.url> | ||
548 | + <!-- 日志 --> | ||
549 | + <dili_titan.log.level>INFO</dili_titan.log.level> | ||
550 | + <dili_titan.log.path>/diliapp/servers/logs</dili_titan.log.path> | ||
551 | + <dili_titan.log.root.appender>FILE_ALL</dili_titan.log.root.appender> | ||
552 | + <!--打包编码 --> | ||
553 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
554 | + <!-- 图片服务器前缀 --> | ||
555 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | ||
556 | + <!--爱奇艺视频 --> | ||
557 | + <titan.aqy.appkey>f689d13d9dce48039cae27e6e03940c6</titan.aqy.appkey> | ||
558 | + <titan.aqy.appSecret>8633dfebb9f4443d0f1244262bca94f6</titan.aqy.appSecret> | ||
559 | + </properties> | ||
560 | + </profile> | ||
561 | + | ||
562 | + <profile> | ||
563 | + <!-- 测试环境 --> | ||
564 | + <id>pnr-clone</id> | ||
565 | + <activation> | ||
566 | + <activeByDefault>false</activeByDefault> | ||
567 | + </activation> | ||
568 | + <properties> | ||
569 | + <!--jdbc type --> | ||
570 | + <dili_titan.jdbc.datasource.type>dbcp | ||
571 | + </dili_titan.jdbc.datasource.type> | ||
572 | + <!-- 数据库 --> | ||
573 | + <dili_titan.jdbc.driver>com.mysql.jdbc.Driver</dili_titan.jdbc.driver> | ||
574 | + <!-- 主库配置 --> | ||
575 | + <dili_titan.master.jdbc.url>jdbc:MySql://10.28.5.236:3306/titan?useUnicode=true&characterEncoding=utf8</dili_titan.master.jdbc.url> | ||
576 | + <dili_titan.master.jdbc.username>root</dili_titan.master.jdbc.username> | ||
577 | + <dili_titan.master.jdbc.password>123456</dili_titan.master.jdbc.password> | ||
578 | + <!-- 从库配置 --> | ||
579 | + <dili_titan.slave.jdbc.url>jdbc:MySql://10.28.5.235:3306/titan?useUnicode=true&characterEncoding=utf8</dili_titan.slave.jdbc.url> | ||
580 | + <dili_titan.slave.jdbc.username>titan_reader</dili_titan.slave.jdbc.username> | ||
581 | + <dili_titan.slave.jdbc.password>123456</dili_titan.slave.jdbc.password> | ||
582 | + <!-- crm接口地址 --> | ||
583 | + <dili_titan.crm.url>supplier.1n4j.com</dili_titan.crm.url> | ||
584 | + <!-- user接口地址,需要测试自己修改 --> | ||
585 | + <dili_titan.user.url>user.1n4j.com</dili_titan.user.url> | ||
586 | + <!--关键字接口地址--> | ||
587 | + <dili_titan.keywords.url>keyword.filter.1n4j.com</dili_titan.keywords.url> | ||
588 | + <!--shop接口地址,需要测试自己修改 --> | ||
589 | + <dili_titan.shop.url>http://shop.1n4j.com</dili_titan.shop.url> | ||
590 | + <!-- redis接口地址 --> | ||
591 | + <dili_titan.redis.url>10.28.5.200</dili_titan.redis.url> | ||
592 | + <!--权限管理的redis配置--> | ||
593 | + <manage.redis.url>10.28.5.200</manage.redis.url> | ||
594 | + <manage.redis.port>6379</manage.redis.port> | ||
595 | + <!-- MQ 地址--> | ||
596 | + <conf.mq.namesrvAddr>10.28.5.202:9876;10.28.5.203:9876</conf.mq.namesrvAddr> | ||
597 | + <conf.mq.producerGroup>titanPNR</conf.mq.producerGroup> | ||
598 | + <!-- website接口地址 --> | ||
599 | + <dili_titan.website.url>manweb.1n4j.com | ||
600 | + </dili_titan.website.url> | ||
601 | + <!-- 日志 --> | ||
602 | + <dili_titan.log.level>INFO</dili_titan.log.level> | ||
603 | + <dili_titan.log.path>/home/tomcat/export</dili_titan.log.path> | ||
604 | + <dili_titan.log.root.appender>CONSOLE | ||
605 | + </dili_titan.log.root.appender> | ||
606 | + <!--打包编码 --> | ||
607 | + <project.build.sourceEncoding>UTF-8 | ||
608 | + </project.build.sourceEncoding> | ||
609 | + <!-- 图片服务器前缀 --> | ||
610 | + <project.imageserver.prefix>http://img0.1n4j.com</project.imageserver.prefix> | ||
611 | + <!--爱奇艺视频 --> | ||
612 | + <titan.aqy.appkey>f689d13d9dce48039cae27e6e03940c6</titan.aqy.appkey> | ||
613 | + <titan.aqy.appSecret>8633dfebb9f4443d0f1244262bca94f6</titan.aqy.appSecret> | ||
614 | + </properties> | ||
615 | + </profile> | ||
616 | + </profiles> | ||
617 | + | ||
618 | +</project> |
titan-api/src/main/hbase-profiles/develop/core-site.xml
0 → 100755
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<configuration> | ||
3 | + | ||
4 | + <property> | ||
5 | + <name>fs.defaultFS</name> | ||
6 | + <value>hdfs://mycluster</value> | ||
7 | + <final>true</final> | ||
8 | + </property> | ||
9 | + | ||
10 | + <property> | ||
11 | + <name>fs.trash.interval</name> | ||
12 | + <value>360</value> | ||
13 | + </property> | ||
14 | + | ||
15 | + <property> | ||
16 | + <name>ha.failover-controller.active-standby-elector.zk.op.retries</name> | ||
17 | + <value>120</value> | ||
18 | + </property> | ||
19 | + | ||
20 | + <property> | ||
21 | + <name>ha.zookeeper.quorum</name> | ||
22 | + <value>node2:2181,node3:2181,node4:2181</value> | ||
23 | + </property> | ||
24 | + | ||
25 | + <property> | ||
26 | + <name>hadoop.http.authentication.simple.anonymous.allowed</name> | ||
27 | + <value>true</value> | ||
28 | + </property> | ||
29 | + | ||
30 | + <property> | ||
31 | + <name>hadoop.security.auth_to_local</name> | ||
32 | + <value>DEFAULT</value> | ||
33 | + </property> | ||
34 | + | ||
35 | + <property> | ||
36 | + <name>hadoop.security.authentication</name> | ||
37 | + <value>simple</value> | ||
38 | + </property> | ||
39 | + | ||
40 | + <property> | ||
41 | + <name>hadoop.security.authorization</name> | ||
42 | + <value>false</value> | ||
43 | + </property> | ||
44 | + | ||
45 | + <property> | ||
46 | + <name>io.compression.codecs</name> | ||
47 | + <value>org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.SnappyCodec</value> | ||
48 | + </property> | ||
49 | + | ||
50 | + <property> | ||
51 | + <name>io.file.buffer.size</name> | ||
52 | + <value>131072</value> | ||
53 | + </property> | ||
54 | + | ||
55 | + <property> | ||
56 | + <name>io.serializations</name> | ||
57 | + <value>org.apache.hadoop.io.serializer.WritableSerialization</value> | ||
58 | + </property> | ||
59 | + | ||
60 | + <property> | ||
61 | + <name>ipc.client.connect.max.retries</name> | ||
62 | + <value>50</value> | ||
63 | + </property> | ||
64 | + | ||
65 | + <property> | ||
66 | + <name>ipc.client.connection.maxidletime</name> | ||
67 | + <value>30000</value> | ||
68 | + </property> | ||
69 | + | ||
70 | + <property> | ||
71 | + <name>ipc.client.idlethreshold</name> | ||
72 | + <value>8000</value> | ||
73 | + </property> | ||
74 | + | ||
75 | + <property> | ||
76 | + <name>ipc.server.tcpnodelay</name> | ||
77 | + <value>true</value> | ||
78 | + </property> | ||
79 | + | ||
80 | + <property> | ||
81 | + <name>mapreduce.jobtracker.webinterface.trusted</name> | ||
82 | + <value>false</value> | ||
83 | + </property> | ||
84 | + | ||
85 | + <property> | ||
86 | + <name>proxyuser_group</name> | ||
87 | + <value>users</value> | ||
88 | + </property> | ||
89 | + | ||
90 | +</configuration> |
titan-api/src/main/hbase-profiles/develop/hbase-site.xml
0 → 100755
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<configuration> | ||
3 | + | ||
4 | + <property> | ||
5 | + <name>dfs.domain.socket.path</name> | ||
6 | + <value>/var/lib/hadoop-hdfs/dn_socket</value> | ||
7 | + </property> | ||
8 | + | ||
9 | + <property> | ||
10 | + <name>hbase.client.keyvalue.maxsize</name> | ||
11 | + <value>10485760</value> | ||
12 | + </property> | ||
13 | + | ||
14 | + <property> | ||
15 | + <name>hbase.client.scanner.caching</name> | ||
16 | + <value>100</value> | ||
17 | + </property> | ||
18 | + | ||
19 | + <property> | ||
20 | + <name>hbase.cluster.distributed</name> | ||
21 | + <value>true</value> | ||
22 | + </property> | ||
23 | + | ||
24 | + <property> | ||
25 | + <name>hbase.coprocessor.master.classes</name> | ||
26 | + <value></value> | ||
27 | + </property> | ||
28 | + | ||
29 | + <property> | ||
30 | + <name>hbase.coprocessor.region.classes</name> | ||
31 | + <value></value> | ||
32 | + </property> | ||
33 | + | ||
34 | + <property> | ||
35 | + <name>hbase.defaults.for.version.skip</name> | ||
36 | + <value>true</value> | ||
37 | + </property> | ||
38 | + | ||
39 | + <property> | ||
40 | + <name>hbase.hregion.majorcompaction</name> | ||
41 | + <value>604800000</value> | ||
42 | + </property> | ||
43 | + | ||
44 | + <property> | ||
45 | + <name>hbase.hregion.majorcompaction.jitter</name> | ||
46 | + <value>0.50</value> | ||
47 | + </property> | ||
48 | + | ||
49 | + <property> | ||
50 | + <name>hbase.hregion.max.filesize</name> | ||
51 | + <value>10737418240</value> | ||
52 | + </property> | ||
53 | + | ||
54 | + <property> | ||
55 | + <name>hbase.hregion.memstore.block.multiplier</name> | ||
56 | + <value>4</value> | ||
57 | + </property> | ||
58 | + | ||
59 | + <property> | ||
60 | + <name>hbase.hregion.memstore.flush.size</name> | ||
61 | + <value>134217728</value> | ||
62 | + </property> | ||
63 | + | ||
64 | + <property> | ||
65 | + <name>hbase.hregion.memstore.mslab.enabled</name> | ||
66 | + <value>true</value> | ||
67 | + </property> | ||
68 | + | ||
69 | + <property> | ||
70 | + <name>hbase.hstore.blockingStoreFiles</name> | ||
71 | + <value>10</value> | ||
72 | + </property> | ||
73 | + | ||
74 | + <property> | ||
75 | + <name>hbase.hstore.compactionThreshold</name> | ||
76 | + <value>3</value> | ||
77 | + </property> | ||
78 | + | ||
79 | + <property> | ||
80 | + <name>hbase.local.dir</name> | ||
81 | + <value>${hbase.tmp.dir}/local</value> | ||
82 | + </property> | ||
83 | + | ||
84 | + <property> | ||
85 | + <name>hbase.master.info.bindAddress</name> | ||
86 | + <value>0.0.0.0</value> | ||
87 | + </property> | ||
88 | + | ||
89 | + <property> | ||
90 | + <name>hbase.master.info.port</name> | ||
91 | + <value>60010</value> | ||
92 | + </property> | ||
93 | + | ||
94 | + <property> | ||
95 | + <name>hbase.master.port</name> | ||
96 | + <value>60000</value> | ||
97 | + </property> | ||
98 | + | ||
99 | + <property> | ||
100 | + <name>hbase.regionserver.global.memstore.lowerLimit</name> | ||
101 | + <value>0.38</value> | ||
102 | + </property> | ||
103 | + | ||
104 | + <property> | ||
105 | + <name>hbase.regionserver.global.memstore.upperLimit</name> | ||
106 | + <value>0.4</value> | ||
107 | + </property> | ||
108 | + | ||
109 | + <property> | ||
110 | + <name>hbase.regionserver.handler.count</name> | ||
111 | + <value>60</value> | ||
112 | + </property> | ||
113 | + | ||
114 | + <property> | ||
115 | + <name>hbase.regionserver.info.port</name> | ||
116 | + <value>60030</value> | ||
117 | + </property> | ||
118 | + | ||
119 | + <property> | ||
120 | + <name>hbase.rootdir</name> | ||
121 | + <value>hdfs://mycluster/apps/hbase/data</value> | ||
122 | + </property> | ||
123 | + | ||
124 | + <property> | ||
125 | + <name>hbase.rpc.protection</name> | ||
126 | + <value>authentication</value> | ||
127 | + </property> | ||
128 | + | ||
129 | + <property> | ||
130 | + <name>hbase.security.authentication</name> | ||
131 | + <value>simple</value> | ||
132 | + </property> | ||
133 | + | ||
134 | + <property> | ||
135 | + <name>hbase.security.authorization</name> | ||
136 | + <value>false</value> | ||
137 | + </property> | ||
138 | + | ||
139 | + <property> | ||
140 | + <name>hbase.superuser</name> | ||
141 | + <value>hadoop</value> | ||
142 | + </property> | ||
143 | + | ||
144 | + <property> | ||
145 | + <name>hbase.zookeeper.property.clientPort</name> | ||
146 | + <value>2181</value> | ||
147 | + </property> | ||
148 | + | ||
149 | + <property> | ||
150 | + <name>hbase.zookeeper.quorum</name> | ||
151 | + <value>node2,node3,node4</value> | ||
152 | + </property> | ||
153 | + | ||
154 | + <property> | ||
155 | + <name>hbase.zookeeper.useMulti</name> | ||
156 | + <value>true</value> | ||
157 | + </property> | ||
158 | + | ||
159 | + <property> | ||
160 | + <name>hfile.block.cache.size</name> | ||
161 | + <value>0.40</value> | ||
162 | + </property> | ||
163 | + | ||
164 | + <property> | ||
165 | + <name>zookeeper.session.timeout</name> | ||
166 | + <value>30000</value> | ||
167 | + </property> | ||
168 | + | ||
169 | + <property> | ||
170 | + <name>zookeeper.znode.parent</name> | ||
171 | + <value>/hbase</value> | ||
172 | + </property> | ||
173 | + | ||
174 | +</configuration> |
titan-api/src/main/hbase-profiles/online/core-site.xml
0 → 100755
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<configuration> | ||
3 | + | ||
4 | + <property> | ||
5 | + <name>fs.defaultFS</name> | ||
6 | + <value>hdfs://bigdata1</value> | ||
7 | + <final>true</final> | ||
8 | + </property> | ||
9 | + | ||
10 | + <property> | ||
11 | + <name>fs.trash.interval</name> | ||
12 | + <value>360</value> | ||
13 | + </property> | ||
14 | + | ||
15 | + <property> | ||
16 | + <name>ha.failover-controller.active-standby-elector.zk.op.retries</name> | ||
17 | + <value>120</value> | ||
18 | + </property> | ||
19 | + | ||
20 | + <property> | ||
21 | + <name>ha.zookeeper.quorum</name> | ||
22 | + <value>ddbigdata.29.115.nong12.com:2181,ddbigdata.29.116.nong12.com:2181,ddbigdata.29.117.nong12.com:2181</value> | ||
23 | + </property> | ||
24 | + | ||
25 | + <property> | ||
26 | + <name>hadoop.http.authentication.simple.anonymous.allowed</name> | ||
27 | + <value>true</value> | ||
28 | + </property> | ||
29 | + | ||
30 | + <property> | ||
31 | + <name>hadoop.security.auth_to_local</name> | ||
32 | + <value>DEFAULT</value> | ||
33 | + </property> | ||
34 | + | ||
35 | + <property> | ||
36 | + <name>hadoop.security.authentication</name> | ||
37 | + <value>simple</value> | ||
38 | + </property> | ||
39 | + | ||
40 | + <property> | ||
41 | + <name>hadoop.security.authorization</name> | ||
42 | + <value>false</value> | ||
43 | + </property> | ||
44 | + | ||
45 | + <property> | ||
46 | + <name>io.compression.codecs</name> | ||
47 | + <value>org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.SnappyCodec</value> | ||
48 | + </property> | ||
49 | + | ||
50 | + <property> | ||
51 | + <name>io.file.buffer.size</name> | ||
52 | + <value>131072</value> | ||
53 | + </property> | ||
54 | + | ||
55 | + <property> | ||
56 | + <name>io.serializations</name> | ||
57 | + <value>org.apache.hadoop.io.serializer.WritableSerialization</value> | ||
58 | + </property> | ||
59 | + | ||
60 | + <property> | ||
61 | + <name>ipc.client.connect.max.retries</name> | ||
62 | + <value>50</value> | ||
63 | + </property> | ||
64 | + | ||
65 | + <property> | ||
66 | + <name>ipc.client.connection.maxidletime</name> | ||
67 | + <value>30000</value> | ||
68 | + </property> | ||
69 | + | ||
70 | + <property> | ||
71 | + <name>ipc.client.idlethreshold</name> | ||
72 | + <value>8000</value> | ||
73 | + </property> | ||
74 | + | ||
75 | + <property> | ||
76 | + <name>ipc.server.tcpnodelay</name> | ||
77 | + <value>true</value> | ||
78 | + </property> | ||
79 | + | ||
80 | + <property> | ||
81 | + <name>mapreduce.jobtracker.webinterface.trusted</name> | ||
82 | + <value>false</value> | ||
83 | + </property> | ||
84 | + | ||
85 | + <property> | ||
86 | + <name>proxyuser_group</name> | ||
87 | + <value>users</value> | ||
88 | + </property> | ||
89 | + | ||
90 | +</configuration> |
titan-api/src/main/hbase-profiles/online/hbase-site.xml
0 → 100755
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<configuration> | ||
3 | + | ||
4 | + <property> | ||
5 | + <name>dfs.domain.socket.path</name> | ||
6 | + <value>/var/lib/hadoop-hdfs/dn_socket</value> | ||
7 | + </property> | ||
8 | + | ||
9 | + <property> | ||
10 | + <name>hbase.client.keyvalue.maxsize</name> | ||
11 | + <value>10485760</value> | ||
12 | + </property> | ||
13 | + | ||
14 | + <property> | ||
15 | + <name>hbase.client.scanner.caching</name> | ||
16 | + <value>100</value> | ||
17 | + </property> | ||
18 | + | ||
19 | + <property> | ||
20 | + <name>hbase.cluster.distributed</name> | ||
21 | + <value>true</value> | ||
22 | + </property> | ||
23 | + | ||
24 | + <property> | ||
25 | + <name>hbase.coprocessor.master.classes</name> | ||
26 | + <value></value> | ||
27 | + </property> | ||
28 | + | ||
29 | + <property> | ||
30 | + <name>hbase.coprocessor.region.classes</name> | ||
31 | + <value></value> | ||
32 | + </property> | ||
33 | + | ||
34 | + <property> | ||
35 | + <name>hbase.defaults.for.version.skip</name> | ||
36 | + <value>true</value> | ||
37 | + </property> | ||
38 | + | ||
39 | + <property> | ||
40 | + <name>hbase.hregion.majorcompaction</name> | ||
41 | + <value>604800000</value> | ||
42 | + </property> | ||
43 | + | ||
44 | + <property> | ||
45 | + <name>hbase.hregion.majorcompaction.jitter</name> | ||
46 | + <value>0.50</value> | ||
47 | + </property> | ||
48 | + | ||
49 | + <property> | ||
50 | + <name>hbase.hregion.max.filesize</name> | ||
51 | + <value>10737418240</value> | ||
52 | + </property> | ||
53 | + | ||
54 | + <property> | ||
55 | + <name>hbase.hregion.memstore.block.multiplier</name> | ||
56 | + <value>4</value> | ||
57 | + </property> | ||
58 | + | ||
59 | + <property> | ||
60 | + <name>hbase.hregion.memstore.flush.size</name> | ||
61 | + <value>134217728</value> | ||
62 | + </property> | ||
63 | + | ||
64 | + <property> | ||
65 | + <name>hbase.hregion.memstore.mslab.enabled</name> | ||
66 | + <value>true</value> | ||
67 | + </property> | ||
68 | + | ||
69 | + <property> | ||
70 | + <name>hbase.hstore.blockingStoreFiles</name> | ||
71 | + <value>10</value> | ||
72 | + </property> | ||
73 | + | ||
74 | + <property> | ||
75 | + <name>hbase.hstore.compactionThreshold</name> | ||
76 | + <value>3</value> | ||
77 | + </property> | ||
78 | + | ||
79 | + <property> | ||
80 | + <name>hbase.local.dir</name> | ||
81 | + <value>${hbase.tmp.dir}/local</value> | ||
82 | + </property> | ||
83 | + | ||
84 | + <property> | ||
85 | + <name>hbase.master.info.bindAddress</name> | ||
86 | + <value>0.0.0.0</value> | ||
87 | + </property> | ||
88 | + | ||
89 | + <property> | ||
90 | + <name>hbase.master.info.port</name> | ||
91 | + <value>60010</value> | ||
92 | + </property> | ||
93 | + | ||
94 | + <property> | ||
95 | + <name>hbase.master.port</name> | ||
96 | + <value>60000</value> | ||
97 | + </property> | ||
98 | + | ||
99 | + <property> | ||
100 | + <name>hbase.regionserver.global.memstore.lowerLimit</name> | ||
101 | + <value>0.38</value> | ||
102 | + </property> | ||
103 | + | ||
104 | + <property> | ||
105 | + <name>hbase.regionserver.global.memstore.upperLimit</name> | ||
106 | + <value>0.4</value> | ||
107 | + </property> | ||
108 | + | ||
109 | + <property> | ||
110 | + <name>hbase.regionserver.handler.count</name> | ||
111 | + <value>60</value> | ||
112 | + </property> | ||
113 | + | ||
114 | + <property> | ||
115 | + <name>hbase.regionserver.info.port</name> | ||
116 | + <value>60030</value> | ||
117 | + </property> | ||
118 | + | ||
119 | + <property> | ||
120 | + <name>hbase.rootdir</name> | ||
121 | + <value>hdfs://bigdata1/apps/hbase/data</value> | ||
122 | + </property> | ||
123 | + | ||
124 | + <property> | ||
125 | + <name>hbase.rpc.protection</name> | ||
126 | + <value>authentication</value> | ||
127 | + </property> | ||
128 | + | ||
129 | + <property> | ||
130 | + <name>hbase.security.authentication</name> | ||
131 | + <value>simple</value> | ||
132 | + </property> | ||
133 | + | ||
134 | + <property> | ||
135 | + <name>hbase.security.authorization</name> | ||
136 | + <value>false</value> | ||
137 | + </property> | ||
138 | + | ||
139 | + <property> | ||
140 | + <name>hbase.superuser</name> | ||
141 | + <value>hbase</value> | ||
142 | + </property> | ||
143 | + | ||
144 | + <!--<property> | ||
145 | + <name>hbase.tmp.dir</name> | ||
146 | + <value>/diliapp/data1/hadoop/hbase</value> | ||
147 | + </property>--> | ||
148 | + | ||
149 | + <property> | ||
150 | + <name>hbase.zookeeper.property.clientPort</name> | ||
151 | + <value>2181</value> | ||
152 | + </property> | ||
153 | + | ||
154 | + <property> | ||
155 | + <name>hbase.zookeeper.quorum</name> | ||
156 | + <value>ddbigdata.29.115.nong12.com:2181,ddbigdata.29.116.nong12.com:2181,ddbigdata.29.117.nong12.com:2181</value> | ||
157 | + </property> | ||
158 | + | ||
159 | + <property> | ||
160 | + <name>hbase.zookeeper.useMulti</name> | ||
161 | + <value>true</value> | ||
162 | + </property> | ||
163 | + | ||
164 | + <property> | ||
165 | + <name>hfile.block.cache.size</name> | ||
166 | + <value>0.40</value> | ||
167 | + </property> | ||
168 | + | ||
169 | + <property> | ||
170 | + <name>zookeeper.session.timeout</name> | ||
171 | + <value>30000</value> | ||
172 | + </property> | ||
173 | + | ||
174 | + <property> | ||
175 | + <name>zookeeper.znode.parent</name> | ||
176 | + <value>/hbase-unsecure</value> | ||
177 | + </property> | ||
178 | + | ||
179 | +</configuration> |
titan-api/src/main/hbase-profiles/pre-online/core-site.xml
0 → 100755
1 | +<!--Mon Nov 14 17:17:58 2016--> | ||
2 | + <configuration> | ||
3 | + | ||
4 | + <property> | ||
5 | + <name>fs.defaultFS</name> | ||
6 | + <value>hdfs://hbase1.hadoop:8020</value> | ||
7 | + <final>true</final> | ||
8 | + </property> | ||
9 | + | ||
10 | + <property> | ||
11 | + <name>fs.trash.interval</name> | ||
12 | + <value>360</value> | ||
13 | + </property> | ||
14 | + | ||
15 | + <property> | ||
16 | + <name>ha.failover-controller.active-standby-elector.zk.op.retries</name> | ||
17 | + <value>120</value> | ||
18 | + </property> | ||
19 | + | ||
20 | + <property> | ||
21 | + <name>hadoop.http.authentication.simple.anonymous.allowed</name> | ||
22 | + <value>true</value> | ||
23 | + </property> | ||
24 | + | ||
25 | + <property> | ||
26 | + <name>hadoop.security.auth_to_local</name> | ||
27 | + <value>DEFAULT</value> | ||
28 | + </property> | ||
29 | + | ||
30 | + <property> | ||
31 | + <name>hadoop.security.authentication</name> | ||
32 | + <value>simple</value> | ||
33 | + </property> | ||
34 | + | ||
35 | + <property> | ||
36 | + <name>hadoop.security.authorization</name> | ||
37 | + <value>false</value> | ||
38 | + </property> | ||
39 | + | ||
40 | + <property> | ||
41 | + <name>io.compression.codecs</name> | ||
42 | + <value>org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.SnappyCodec</value> | ||
43 | + </property> | ||
44 | + | ||
45 | + <property> | ||
46 | + <name>io.file.buffer.size</name> | ||
47 | + <value>131072</value> | ||
48 | + </property> | ||
49 | + | ||
50 | + <property> | ||
51 | + <name>io.serializations</name> | ||
52 | + <value>org.apache.hadoop.io.serializer.WritableSerialization</value> | ||
53 | + </property> | ||
54 | + | ||
55 | + <property> | ||
56 | + <name>ipc.client.connect.max.retries</name> | ||
57 | + <value>50</value> | ||
58 | + </property> | ||
59 | + | ||
60 | + <property> | ||
61 | + <name>ipc.client.connection.maxidletime</name> | ||
62 | + <value>30000</value> | ||
63 | + </property> | ||
64 | + | ||
65 | + <property> | ||
66 | + <name>ipc.client.idlethreshold</name> | ||
67 | + <value>8000</value> | ||
68 | + </property> | ||
69 | + | ||
70 | + <property> | ||
71 | + <name>ipc.server.tcpnodelay</name> | ||
72 | + <value>true</value> | ||
73 | + </property> | ||
74 | + | ||
75 | + <property> | ||
76 | + <name>mapreduce.jobtracker.webinterface.trusted</name> | ||
77 | + <value>false</value> | ||
78 | + </property> | ||
79 | + | ||
80 | + <property> | ||
81 | + <name>proxyuser_group</name> | ||
82 | + <value>users</value> | ||
83 | + </property> | ||
84 | + | ||
85 | + </configuration> |
titan-api/src/main/hbase-profiles/pre-online/hbase-site.xml
0 → 100755
1 | +<!--Mon Nov 14 17:18:24 2016--> | ||
2 | + <configuration> | ||
3 | + | ||
4 | + <property> | ||
5 | + <name>dfs.domain.socket.path</name> | ||
6 | + <value>/var/lib/hadoop-hdfs/dn_socket</value> | ||
7 | + </property> | ||
8 | + | ||
9 | + <property> | ||
10 | + <name>hbase.client.keyvalue.maxsize</name> | ||
11 | + <value>10485760</value> | ||
12 | + </property> | ||
13 | + | ||
14 | + <property> | ||
15 | + <name>hbase.client.scanner.caching</name> | ||
16 | + <value>100</value> | ||
17 | + </property> | ||
18 | + | ||
19 | + <property> | ||
20 | + <name>hbase.cluster.distributed</name> | ||
21 | + <value>true</value> | ||
22 | + </property> | ||
23 | + | ||
24 | + <property> | ||
25 | + <name>hbase.coprocessor.master.classes</name> | ||
26 | + <value></value> | ||
27 | + </property> | ||
28 | + | ||
29 | + <property> | ||
30 | + <name>hbase.coprocessor.region.classes</name> | ||
31 | + <value></value> | ||
32 | + </property> | ||
33 | + | ||
34 | + <property> | ||
35 | + <name>hbase.defaults.for.version.skip</name> | ||
36 | + <value>true</value> | ||
37 | + </property> | ||
38 | + | ||
39 | + <property> | ||
40 | + <name>hbase.hregion.majorcompaction</name> | ||
41 | + <value>604800000</value> | ||
42 | + </property> | ||
43 | + | ||
44 | + <property> | ||
45 | + <name>hbase.hregion.majorcompaction.jitter</name> | ||
46 | + <value>0.50</value> | ||
47 | + </property> | ||
48 | + | ||
49 | + <property> | ||
50 | + <name>hbase.hregion.max.filesize</name> | ||
51 | + <value>10737418240</value> | ||
52 | + </property> | ||
53 | + | ||
54 | + <property> | ||
55 | + <name>hbase.hregion.memstore.block.multiplier</name> | ||
56 | + <value>4</value> | ||
57 | + </property> | ||
58 | + | ||
59 | + <property> | ||
60 | + <name>hbase.hregion.memstore.flush.size</name> | ||
61 | + <value>134217728</value> | ||
62 | + </property> | ||
63 | + | ||
64 | + <property> | ||
65 | + <name>hbase.hregion.memstore.mslab.enabled</name> | ||
66 | + <value>true</value> | ||
67 | + </property> | ||
68 | + | ||
69 | + <property> | ||
70 | + <name>hbase.hstore.blockingStoreFiles</name> | ||
71 | + <value>10</value> | ||
72 | + </property> | ||
73 | + | ||
74 | + <property> | ||
75 | + <name>hbase.hstore.compactionThreshold</name> | ||
76 | + <value>3</value> | ||
77 | + </property> | ||
78 | + | ||
79 | + <property> | ||
80 | + <name>hbase.local.dir</name> | ||
81 | + <value>${hbase.tmp.dir}/local</value> | ||
82 | + </property> | ||
83 | + | ||
84 | + <property> | ||
85 | + <name>hbase.master.info.bindAddress</name> | ||
86 | + <value>0.0.0.0</value> | ||
87 | + </property> | ||
88 | + | ||
89 | + <property> | ||
90 | + <name>hbase.master.info.port</name> | ||
91 | + <value>60010</value> | ||
92 | + </property> | ||
93 | + | ||
94 | + <property> | ||
95 | + <name>hbase.master.port</name> | ||
96 | + <value>60000</value> | ||
97 | + </property> | ||
98 | + | ||
99 | + <property> | ||
100 | + <name>hbase.regionserver.global.memstore.lowerLimit</name> | ||
101 | + <value>0.38</value> | ||
102 | + </property> | ||
103 | + | ||
104 | + <property> | ||
105 | + <name>hbase.regionserver.global.memstore.upperLimit</name> | ||
106 | + <value>0.4</value> | ||
107 | + </property> | ||
108 | + | ||
109 | + <property> | ||
110 | + <name>hbase.regionserver.handler.count</name> | ||
111 | + <value>60</value> | ||
112 | + </property> | ||
113 | + | ||
114 | + <property> | ||
115 | + <name>hbase.regionserver.info.port</name> | ||
116 | + <value>60030</value> | ||
117 | + </property> | ||
118 | + | ||
119 | + <property> | ||
120 | + <name>hbase.rootdir</name> | ||
121 | + <value>hdfs://hbase1.hadoop:8020/apps/hbase/data</value> | ||
122 | + </property> | ||
123 | + | ||
124 | + <property> | ||
125 | + <name>hbase.rpc.protection</name> | ||
126 | + <value>authentication</value> | ||
127 | + </property> | ||
128 | + | ||
129 | + <property> | ||
130 | + <name>hbase.security.authentication</name> | ||
131 | + <value>simple</value> | ||
132 | + </property> | ||
133 | + | ||
134 | + <property> | ||
135 | + <name>hbase.security.authorization</name> | ||
136 | + <value>false</value> | ||
137 | + </property> | ||
138 | + | ||
139 | + <property> | ||
140 | + <name>hbase.superuser</name> | ||
141 | + <value>hbase</value> | ||
142 | + </property> | ||
143 | + | ||
144 | + <property> | ||
145 | + <name>hbase.tmp.dir</name> | ||
146 | + <value>/hadoop/hbase</value> | ||
147 | + </property> | ||
148 | + | ||
149 | + <property> | ||
150 | + <name>hbase.zookeeper.property.clientPort</name> | ||
151 | + <value>2181</value> | ||
152 | + </property> | ||
153 | + | ||
154 | + <property> | ||
155 | + <name>hbase.zookeeper.quorum</name> | ||
156 | + <value>hbase2.hadoop,hbase1.hadoop,hbase3.hadoop</value> | ||
157 | + </property> | ||
158 | + | ||
159 | + <property> | ||
160 | + <name>hbase.zookeeper.useMulti</name> | ||
161 | + <value>true</value> | ||
162 | + </property> | ||
163 | + | ||
164 | + <property> | ||
165 | + <name>hfile.block.cache.size</name> | ||
166 | + <value>0.40</value> | ||
167 | + </property> | ||
168 | + | ||
169 | + <property> | ||
170 | + <name>zookeeper.session.timeout</name> | ||
171 | + <value>30000</value> | ||
172 | + </property> | ||
173 | + | ||
174 | + <property> | ||
175 | + <name>zookeeper.znode.parent</name> | ||
176 | + <value>/hbase-unsecure</value> | ||
177 | + </property> | ||
178 | + | ||
179 | + </configuration> |
titan-api/src/main/hbase-profiles/test/core-site.xml
0 → 100755
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | ||
3 | +<!-- | ||
4 | + Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + you may not use this file except in compliance with the License. | ||
6 | + You may obtain a copy of the License at | ||
7 | + | ||
8 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + | ||
10 | + Unless required by applicable law or agreed to in writing, software | ||
11 | + distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + See the License for the specific language governing permissions and | ||
14 | + limitations under the License. See accompanying LICENSE file. | ||
15 | +--> | ||
16 | + | ||
17 | +<!-- Put site-specific property overrides in this file. --> | ||
18 | + | ||
19 | +<configuration> | ||
20 | + <property> | ||
21 | + <name>hadoop.tmp.dir</name> | ||
22 | + <value>/usr/hadoop/tmp</value> | ||
23 | + </property> | ||
24 | + <property> | ||
25 | + <name>io.file.buffer.size</name> | ||
26 | + <value>131072</value> | ||
27 | + </property> | ||
28 | + <property> | ||
29 | + <name>fs.defaultFS</name> | ||
30 | + <value>hdfs://testcluster</value> | ||
31 | + </property> | ||
32 | + <property> | ||
33 | + <name>hadoop.proxyuser.hadoop.groups</name> | ||
34 | + <value>hadoop</value> | ||
35 | + </property> | ||
36 | + <property> | ||
37 | + <name>hadoop.proxyuser.hadoop.hosts</name> | ||
38 | + <value>*</value> | ||
39 | + </property> | ||
40 | +</configuration> |
titan-api/src/main/hbase-profiles/test/hbase-site.xml
0 → 100755
1 | +<?xml version="1.0"?> | ||
2 | +<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | ||
3 | +<!-- | ||
4 | +/** | ||
5 | + * | ||
6 | + * Licensed to the Apache Software Foundation (ASF) under one | ||
7 | + * or more contributor license agreements. See the NOTICE file | ||
8 | + * distributed with this work for additional information | ||
9 | + * regarding copyright ownership. The ASF licenses this file | ||
10 | + * to you under the Apache License, Version 2.0 (the | ||
11 | + * "License"); you may not use this file except in compliance | ||
12 | + * with the License. You may obtain a copy of the License at | ||
13 | + * | ||
14 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
15 | + * | ||
16 | + * Unless required by applicable law or agreed to in writing, software | ||
17 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
18 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
19 | + * See the License for the specific language governing permissions and | ||
20 | + * limitations under the License. | ||
21 | + */ | ||
22 | +--> | ||
23 | +<configuration> | ||
24 | + <property> | ||
25 | + <name>hbase.rootdir</name> | ||
26 | + <value>hdfs://testcluster/hbase</value> | ||
27 | + </property> | ||
28 | + <property> | ||
29 | + <name>hbase.cluster.distributed</name> | ||
30 | + <value>true</value> | ||
31 | + </property> | ||
32 | + <property> | ||
33 | + <name>hbase.zookeeper.quorum</name> | ||
34 | + <value>server13,server12,server55</value> | ||
35 | + </property> | ||
36 | + | ||
37 | + <!--HBase retry times--> | ||
38 | + <property> | ||
39 | + <name>hbase.client.retries.number</name> | ||
40 | + <value>1</value> | ||
41 | + </property> | ||
42 | +</configuration> |
titan-api/src/main/java/com/dili/titan/common/Account.java
0 → 100755
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-api/src/main/java/com/dili/titan/common/HttpRequester.java
0 → 100755
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.nio.charset.Charset; | ||
10 | +import java.util.Map; | ||
11 | +import java.util.Vector; | ||
12 | + | ||
13 | +/** | ||
14 | + * HTTP请求对象 | ||
15 | + * | ||
16 | + * @author dev-center | ||
17 | + * @since 2014-05-10 | ||
18 | + */ | ||
19 | +public class HttpRequester { | ||
20 | + private String defaultContentEncoding; | ||
21 | + | ||
22 | + public HttpRequester() { | ||
23 | + this.defaultContentEncoding = "UTF-8"; | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * 发送GET请求 | ||
28 | + * | ||
29 | + * @param urlString | ||
30 | + * URL地址 | ||
31 | + * @return 响应对象 | ||
32 | + * @throws IOException | ||
33 | + */ | ||
34 | + public HttpResponse sendGet(String urlString) throws IOException { | ||
35 | + return this.send(urlString, "GET", null, null); | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * 发送GET请求 | ||
40 | + * | ||
41 | + * @param urlString | ||
42 | + * URL地址 | ||
43 | + * @param params | ||
44 | + * 参数集合 | ||
45 | + * @return 响应对象 | ||
46 | + * @throws IOException | ||
47 | + */ | ||
48 | + public HttpResponse sendGet(String urlString, Map<String, String> params) throws IOException { | ||
49 | + return this.send(urlString, "GET", params, null); | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * 发送GET请求 | ||
54 | + * | ||
55 | + * @param urlString | ||
56 | + * URL地址 | ||
57 | + * @param params | ||
58 | + * 参数集合 | ||
59 | + * @param propertys | ||
60 | + * 请求属性 | ||
61 | + * @return 响应对象 | ||
62 | + * @throws IOException | ||
63 | + */ | ||
64 | + public HttpResponse sendGet(String urlString, Map<String, String> params, Map<String, String> propertys) throws IOException { | ||
65 | + return this.send(urlString, "GET", params, propertys); | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * 发送POST请求 | ||
70 | + * | ||
71 | + * @param urlString | ||
72 | + * URL地址 | ||
73 | + * @return 响应对象 | ||
74 | + * @throws IOException | ||
75 | + */ | ||
76 | + public HttpResponse sendPost(String urlString) throws IOException { | ||
77 | + return this.send(urlString, "POST", null, null); | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * 发送POST请求 | ||
82 | + * | ||
83 | + * @param urlString | ||
84 | + * URL地址 | ||
85 | + * @param params | ||
86 | + * 参数集合 | ||
87 | + * @return 响应对象 | ||
88 | + * @throws IOException | ||
89 | + */ | ||
90 | + public HttpResponse sendPost(String urlString, Map<String, String> params) throws IOException { | ||
91 | + return this.send(urlString, "POST", params, null); | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * 发送POST请求 | ||
96 | + * | ||
97 | + * @param urlString | ||
98 | + * URL地址 | ||
99 | + * @param params | ||
100 | + * 参数集合 | ||
101 | + * @param propertys | ||
102 | + * 请求属性 | ||
103 | + * @return 响应对象 | ||
104 | + * @throws IOException | ||
105 | + */ | ||
106 | + public HttpResponse sendPost(String urlString, Map<String, String> params, Map<String, String> propertys) throws IOException { | ||
107 | + return this.send(urlString, "POST", params, propertys); | ||
108 | + } | ||
109 | + | ||
110 | + /** | ||
111 | + * 发送HTTP请求 | ||
112 | + * | ||
113 | + * @param urlString | ||
114 | + * @return 响映对象 | ||
115 | + * @throws IOException | ||
116 | + */ | ||
117 | + private HttpResponse send(String urlString, String method, Map<String, String> parameters, Map<String, String> propertys) throws IOException { | ||
118 | + HttpURLConnection urlConnection = null; | ||
119 | + | ||
120 | + if ("GET".equalsIgnoreCase(method) && parameters != null) { | ||
121 | + StringBuffer param = new StringBuffer(); | ||
122 | + int i = 0; | ||
123 | + for (Map.Entry<String,String> entry : parameters.entrySet()) { | ||
124 | + if (i == 0) | ||
125 | + param.append("?"); | ||
126 | + else | ||
127 | + param.append("&"); | ||
128 | + param.append(entry.getKey()).append("=").append(entry.getValue()); | ||
129 | + i++; | ||
130 | + } | ||
131 | + urlString += param; | ||
132 | + } | ||
133 | + URL url = new URL(urlString); | ||
134 | + urlConnection = (HttpURLConnection) url.openConnection(); | ||
135 | + | ||
136 | + urlConnection.setRequestMethod(method); | ||
137 | + urlConnection.setDoOutput(true); | ||
138 | + urlConnection.setDoInput(true); | ||
139 | + urlConnection.setUseCaches(false); | ||
140 | + | ||
141 | + if (propertys != null) | ||
142 | + for (Map.Entry<String,String> entry : propertys.entrySet()) { | ||
143 | + urlConnection.addRequestProperty(entry.getKey(), entry.getValue()); | ||
144 | + } | ||
145 | + | ||
146 | + if ("POST".equalsIgnoreCase(method) && parameters != null) { | ||
147 | + StringBuffer param = new StringBuffer(); | ||
148 | + for (Map.Entry<String,String> entry : parameters.entrySet()) { | ||
149 | + param.append("&"); | ||
150 | + param.append(entry.getKey()).append("=").append(entry.getValue()); | ||
151 | + } | ||
152 | + urlConnection.getOutputStream().write(param.toString().getBytes(Charset.forName(this.defaultContentEncoding))); | ||
153 | + urlConnection.getOutputStream().flush(); | ||
154 | + urlConnection.getOutputStream().close(); | ||
155 | + } | ||
156 | + | ||
157 | + return this.makeContent(urlString, urlConnection); | ||
158 | + } | ||
159 | + | ||
160 | + /** | ||
161 | + * 得到响应对象 | ||
162 | + * | ||
163 | + * @param urlConnection | ||
164 | + * @return 响应对象 | ||
165 | + * @throws IOException | ||
166 | + */ | ||
167 | + private HttpResponse makeContent(String urlString, HttpURLConnection urlConnection) throws IOException { | ||
168 | + HttpResponse httpResponser = new HttpResponse(); | ||
169 | + try { | ||
170 | + InputStream in = urlConnection.getInputStream(); | ||
171 | + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in,this.defaultContentEncoding)); | ||
172 | + httpResponser.contentCollection = new Vector<String>(); | ||
173 | + StringBuffer temp = new StringBuffer(); | ||
174 | + String line = bufferedReader.readLine(); | ||
175 | + while (line != null) { | ||
176 | + httpResponser.contentCollection.add(line); | ||
177 | + temp.append(line).append("\r\n"); | ||
178 | + line = bufferedReader.readLine(); | ||
179 | + } | ||
180 | + bufferedReader.close(); | ||
181 | + | ||
182 | + String ecod = urlConnection.getContentEncoding(); | ||
183 | + if (ecod == null) | ||
184 | + ecod = this.defaultContentEncoding; | ||
185 | + | ||
186 | + httpResponser.urlString = urlString; | ||
187 | + | ||
188 | + httpResponser.defaultPort = urlConnection.getURL().getDefaultPort(); | ||
189 | + httpResponser.file = urlConnection.getURL().getFile(); | ||
190 | + httpResponser.host = urlConnection.getURL().getHost(); | ||
191 | + httpResponser.path = urlConnection.getURL().getPath(); | ||
192 | + httpResponser.port = urlConnection.getURL().getPort(); | ||
193 | + httpResponser.protocol = urlConnection.getURL().getProtocol(); | ||
194 | + httpResponser.query = urlConnection.getURL().getQuery(); | ||
195 | + httpResponser.ref = urlConnection.getURL().getRef(); | ||
196 | + httpResponser.userInfo = urlConnection.getURL().getUserInfo(); | ||
197 | + | ||
198 | + httpResponser.content = new String(temp.toString().getBytes(Charset.forName(this.defaultContentEncoding)), ecod); | ||
199 | + httpResponser.contentEncoding = ecod; | ||
200 | + httpResponser.code = urlConnection.getResponseCode(); | ||
201 | + httpResponser.message = urlConnection.getResponseMessage(); | ||
202 | + httpResponser.contentType = urlConnection.getContentType(); | ||
203 | + httpResponser.method = urlConnection.getRequestMethod(); | ||
204 | + httpResponser.connectTimeout = urlConnection.getConnectTimeout(); | ||
205 | + httpResponser.readTimeout = urlConnection.getReadTimeout(); | ||
206 | + | ||
207 | + return httpResponser; | ||
208 | + } catch (IOException e) { | ||
209 | + throw e; | ||
210 | + } finally { | ||
211 | + if (urlConnection != null) | ||
212 | + urlConnection.disconnect(); | ||
213 | + } | ||
214 | + } | ||
215 | + | ||
216 | + /** | ||
217 | + * 默认的响应字符集 | ||
218 | + */ | ||
219 | + public String getDefaultContentEncoding() { | ||
220 | + return this.defaultContentEncoding; | ||
221 | + } | ||
222 | + | ||
223 | + /** | ||
224 | + * 设置默认的响应字符集 | ||
225 | + */ | ||
226 | + public void setDefaultContentEncoding(String defaultContentEncoding) { | ||
227 | + this.defaultContentEncoding = defaultContentEncoding; | ||
228 | + } | ||
229 | +} |
titan-api/src/main/java/com/dili/titan/common/HttpResponse.java
0 → 100755
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 | +} |
titan-api/src/main/java/com/dili/titan/common/MapKey.java
0 → 100755
1 | +package com.dili.titan.common; | ||
2 | + | ||
3 | +import java.lang.annotation.Retention; | ||
4 | +import java.lang.annotation.Target; | ||
5 | + | ||
6 | +import static java.lang.annotation.ElementType.FIELD; | ||
7 | +import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
8 | + | ||
9 | +/** | ||
10 | + * <p>Title: 〈标题〉</p> | ||
11 | + * <p>Description: 〈描述〉</p> | ||
12 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | ||
13 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
14 | + * <B>Company</B> 地利集团 | ||
15 | + * <p>CreateTime:2015/4/1</p> | ||
16 | + * | ||
17 | + * @author gongsz | ||
18 | + */ | ||
19 | +@Target({FIELD}) | ||
20 | +@Retention(RUNTIME) | ||
21 | +public @interface MapKey { | ||
22 | + | ||
23 | +} |
titan-api/src/main/java/com/dili/titan/common/ProductStatus.java
0 → 100755
1 | +package com.dili.titan.common; | ||
2 | + | ||
3 | +public class ProductStatus { | ||
4 | + | ||
5 | + /** | ||
6 | + * 第三方销售 | ||
7 | + */ | ||
8 | + public static final String SALE_TYPE_POP = "30"; | ||
9 | + | ||
10 | + /** | ||
11 | + * 第三方商品 | ||
12 | + */ | ||
13 | + public static final int PRODUCT_POP = 1; | ||
14 | + | ||
15 | + /** | ||
16 | + * 商品预览状态 | ||
17 | + */ | ||
18 | + public static final int PRODUCT_PREVIEW = -2; | ||
19 | + | ||
20 | + /** | ||
21 | + * 商品删除状态 | ||
22 | + */ | ||
23 | + public static final int PRODUCT_DELETED = -1; | ||
24 | + | ||
25 | + /** | ||
26 | + * 新建待审核商品 | ||
27 | + */ | ||
28 | + public static final int PRODUCT_NEW = 1; | ||
29 | + | ||
30 | + /** | ||
31 | + * 审核失败商品 | ||
32 | + */ | ||
33 | + public static final int PRODUCT_DENIED = 2; | ||
34 | + | ||
35 | + /** | ||
36 | + * 在架商品,在售商品 | ||
37 | + */ | ||
38 | + public static final int PRODUCT_ONSALE = 3; | ||
39 | + | ||
40 | + /** | ||
41 | + * 在仓库中的商品,审核后直接放入仓库的商品 | ||
42 | + */ | ||
43 | + public static final int PRODUCT_IN_WAREHOUSE = 4; | ||
44 | + /** | ||
45 | + * 等待上架的商品 | ||
46 | + */ | ||
47 | + public static final int PRODUCT_WAITING_ONSALE = 5; | ||
48 | + /** | ||
49 | + * 过期下架的商品 | ||
50 | + */ | ||
51 | + public static final int PRODUCT_OVERDUE_DROPS = 6; | ||
52 | + /** | ||
53 | + * 手动下架 | ||
54 | + */ | ||
55 | + public static final int PRODUCT_MANUALLY_DROPS = 7; | ||
56 | + | ||
57 | + /** | ||
58 | + * 放入仓库 | ||
59 | + */ | ||
60 | + public static final int PRODUCT_PUBLISH_WAREHOUSE = 1; | ||
61 | + /** | ||
62 | + * 立即上架 | ||
63 | + */ | ||
64 | + public static final int PRODUCT_PUBLISH_IMMEDIATELY = 2; | ||
65 | + /** | ||
66 | + * 指定时间上架 | ||
67 | + */ | ||
68 | + public static final int PRODUCT_PUBLISH_SPECIFY_TIME = 3; | ||
69 | + | ||
70 | + /** | ||
71 | + * 非价格区间商品 | ||
72 | + */ | ||
73 | + public static final int PRODUCT_QUOTATION_FALSE=1; | ||
74 | + | ||
75 | + /** | ||
76 | + * 价格区间的商品 | ||
77 | + */ | ||
78 | + public static final int PRODUCT_QUOTATION_TRUE=2; | ||
79 | + | ||
80 | + /** | ||
81 | + * 普通商品 | ||
82 | + */ | ||
83 | + public static final int PRODUCT_TYPE_GROUP_BUYING=0; | ||
84 | + | ||
85 | + /** | ||
86 | + * 拼购商品 | ||
87 | + */ | ||
88 | + public static final int PRODUCT_TYPE_NOGROUP_BUYING=1; | ||
89 | + | ||
90 | + /** | ||
91 | + * 无样品 | ||
92 | + */ | ||
93 | + public static final int PRODUCT_IS_AMPLE=0; | ||
94 | + | ||
95 | + /** | ||
96 | + * 有样品 | ||
97 | + */ | ||
98 | + public static final int PRODUCT_ISNO_AMPLE=1; | ||
99 | + | ||
100 | +} |
titan-api/src/main/java/com/dili/titan/common/datasource/DataSourceAspect.java
0 → 100755
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(method == null ){ | ||
37 | + return pjp.proceed(); | ||
38 | + } | ||
39 | + log.debug("before:" + method.getName()); | ||
40 | + if (CONTEX.get() == null) { | ||
41 | + log.debug("before:" + method.getName()); | ||
42 | + CONTEX.set(method); | ||
43 | + } | ||
44 | + if (!CONTEX_THOLDER.get()) { | ||
45 | + if (method.isAnnotationPresent(Transactional.class)) { | ||
46 | + String lookUpKey = DataSourceSwitcher.WRITE + (DataSourceSwitcher.RANDOM.nextInt(mastersCount) + 1); | ||
47 | + log.info("Aspect获取数据源" + lookUpKey); | ||
48 | + DataSourceSwitcher.setDataSource(lookUpKey); | ||
49 | + CONTEX_THOLDER.set(true); | ||
50 | + } else { | ||
51 | + DataSourceSwitcher.setDataSource(DataSourceSwitcher.READ); | ||
52 | + } | ||
53 | + } | ||
54 | + Object val = pjp.proceed(); | ||
55 | + if (CONTEX.get() == method) { | ||
56 | + CONTEX.set(null); | ||
57 | + CONTEX_THOLDER.set(false); | ||
58 | + log.debug("after:" + method.getName()); | ||
59 | + } | ||
60 | + log.debug("after:" + method.getName()); | ||
61 | + return val; | ||
62 | + } | ||
63 | + | ||
64 | + public Integer getMastersCount() { | ||
65 | + return mastersCount; | ||
66 | + } | ||
67 | + | ||
68 | + public void setMastersCount(Integer mastersCount) { | ||
69 | + this.mastersCount = mastersCount; | ||
70 | + } | ||
71 | +} |
titan-api/src/main/java/com/dili/titan/common/datasource/DataSourceSwitcher.java
0 → 100755
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 | +} |
titan-api/src/main/java/com/dili/titan/common/datasource/DynamicDataSource.java
0 → 100755
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-api/src/main/java/com/dili/titan/common/datasource/DynamicSource.java
0 → 100755
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 | \ No newline at end of file | 18 | \ No newline at end of file |
titan-api/src/main/java/com/dili/titan/common/exception/AppException.java
0 → 100755
1 | +/* | ||
2 | + * Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
3 | + * 本软件源代码版权归----所有,未经许可不得任意复制与传播. | ||
4 | + */ | ||
5 | +package com.dili.titan.common.exception; | ||
6 | + | ||
7 | +/** | ||
8 | + * AppException | ||
9 | + * @author dev-center | ||
10 | + * @since 2014-05-10 | ||
11 | + */ | ||
12 | +public class AppException extends RuntimeException{ | ||
13 | + private static final long serialVersionUID = 1L; | ||
14 | + public AppException() { | ||
15 | + super(); | ||
16 | + } | ||
17 | + | ||
18 | + public AppException(String message) { | ||
19 | + super(message); | ||
20 | + } | ||
21 | + | ||
22 | + public AppException(String message, Throwable cause) { | ||
23 | + super(message, cause); | ||
24 | + } | ||
25 | + | ||
26 | + public AppException(Throwable cause) { | ||
27 | + super(cause); | ||
28 | + } | ||
29 | +} |
titan-api/src/main/java/com/dili/titan/common/exception/TitanError.java
0 → 100755
1 | +package com.dili.titan.common.exception; | ||
2 | + | ||
3 | +public final class TitanError extends Exception { | ||
4 | + | ||
5 | + /** | ||
6 | + * | ||
7 | + */ | ||
8 | + private static final long serialVersionUID = 1L; | ||
9 | + private int code; | ||
10 | + private String result; | ||
11 | + | ||
12 | + public TitanError(int code, String result) { | ||
13 | + super(); | ||
14 | + this.code = code; | ||
15 | + this.result = result; | ||
16 | + } | ||
17 | + | ||
18 | + public final static TitanError DEFAULT_ERROR = new TitanError(0, "请求失败"); | ||
19 | + | ||
20 | + // 输入错误 | ||
21 | + public final static TitanError JSON_CONVERT_ERROR = new TitanError(10, "JSON转换失败,请检查输入参数"); | ||
22 | + public final static TitanError JSON_FORMAT_ERROR = new TitanError(11, "JSON格式错误"); | ||
23 | + public final static TitanError NULL_PARAM_ERROR = new TitanError(12, "输入参数为空"); | ||
24 | + public final static TitanError INVALID_PARAM_ERROR = new TitanError(13, "输入参数不正确"); | ||
25 | + | ||
26 | + public final static TitanError READ_BODY_ERROR = new TitanError(20, "读取请求内容失败"); | ||
27 | + | ||
28 | + /*** 业务错误 **/ | ||
29 | + // 库存错误 | ||
30 | + public final static TitanError LOW_STOCKS = new TitanError(30, "库存不足"); | ||
31 | + public final static TitanError DUPLICATE_DECRASE = new TitanError(31, "重复扣减库存"); | ||
32 | + public final static TitanError DUPLICATE_INCRASE = new TitanError(31, "重复增加库存"); | ||
33 | + | ||
34 | + public final static TitanError UPDATE_STATE_ERROR = new TitanError(33, "更新数据失败!"); | ||
35 | + | ||
36 | + public final static TitanError NOT_FOUND_CATEGORY = new TitanError(35, "没有找到该类目!"); | ||
37 | + public final static TitanError CATEGORY_HAS_CHILD = new TitanError(36, "该类目不是最后一级!"); | ||
38 | + public final static TitanError CATEGORY_STATE_ERROR = new TitanError(37, "该类目状态不正确!"); | ||
39 | + | ||
40 | + public final static TitanError SUPPLY_STATE_SHUT = new TitanError(38, "供应单已经关闭!"); | ||
41 | + public final static TitanError NOT_FOUND_SUPPLY = new TitanError(39, "没有找到对应的供应单!"); | ||
42 | + public final static TitanError SUPPLY_ALREADY_INQUIRY = new TitanError(40, "供应单已经询价!"); | ||
43 | + | ||
44 | + public final static TitanError PURCHASE_STATE_SHUT = new TitanError(41, "求购单已经关闭!"); | ||
45 | + public final static TitanError NOT_FOUND_PURCHASE = new TitanError(42, "没有找到对应的求购单!"); | ||
46 | + public final static TitanError PURCHASE_ALREADY_INQUIRY = new TitanError(43, "求购单已经报价!"); | ||
47 | + | ||
48 | + public final static TitanError NOT_OPERATION_DATA = new TitanError(43, "没有权限操作此数据!"); | ||
49 | + | ||
50 | + public int getCode() { | ||
51 | + return code; | ||
52 | + } | ||
53 | + | ||
54 | + public void setCode(int code) { | ||
55 | + this.code = code; | ||
56 | + } | ||
57 | + | ||
58 | + public String getResult() { | ||
59 | + return result; | ||
60 | + } | ||
61 | + | ||
62 | + public void setResult(String result) { | ||
63 | + this.result = result; | ||
64 | + } | ||
65 | + | ||
66 | + @Override | ||
67 | + public String getMessage() { | ||
68 | + return this.getResult(); | ||
69 | + } | ||
70 | + | ||
71 | +} |
titan-api/src/main/java/com/dili/titan/common/log/LogBusinessIdUtils.java
0 → 100755
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 | + * @author cdwangyong3 | ||
10 | + * | ||
11 | + */ | ||
12 | +public class LogBusinessIdUtils { | ||
13 | + private static final ThreadLocal<String> businessLocal = new ThreadLocal<String>(); | ||
14 | + /** | ||
15 | + * 返回当前线程对应的uuid | ||
16 | + * @return | ||
17 | + */ | ||
18 | + public static String getCurBusinessId(){ | ||
19 | + String uuid = businessLocal.get(); | ||
20 | + if(StringUtils.isEmpty(uuid)){ | ||
21 | + uuid = UUID.randomUUID().toString().replace("-", ""); | ||
22 | + businessLocal.set(uuid); | ||
23 | + } | ||
24 | + return uuid; | ||
25 | + } | ||
26 | + | ||
27 | + | ||
28 | + /** | ||
29 | + * 给当前线程重新设置 | ||
30 | + */ | ||
31 | + public static void clear(){ | ||
32 | + businessLocal.set(null); | ||
33 | + } | ||
34 | +} |
titan-api/src/main/java/com/dili/titan/common/log/LogHelper.java
0 → 100755
1 | +package com.dili.titan.common.log; | ||
2 | + | ||
3 | +import org.apache.commons.lang.StringUtils; | ||
4 | +import org.slf4j.Logger; | ||
5 | +import org.slf4j.LoggerFactory; | ||
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 | + * stock相关重要日志 | ||
19 | + */ | ||
20 | + private static Map<LogTypeEnum, Logger> logMap = new HashMap<LogTypeEnum, Logger>(); | ||
21 | + | ||
22 | + static { | ||
23 | + for (LogTypeEnum ft : LogTypeEnum.values()) { | ||
24 | + logMap.put(ft, LoggerFactory.getLogger(ft.getKey())); | ||
25 | + } | ||
26 | + } | ||
27 | + | ||
28 | + /** | ||
29 | + * | ||
30 | + * @param str | ||
31 | + * @return | ||
32 | + */ | ||
33 | + public static String addLogbusinessId(String str) { | ||
34 | + if (StringUtils.isEmpty(str)) { | ||
35 | + return str; | ||
36 | + } else { | ||
37 | + return "业务标示ID[" + LogBusinessIdUtils.getCurBusinessId() + "]," | ||
38 | + + str; | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * 使用默认的文件记录debug信息 | ||
44 | + * | ||
45 | + * @param str 日志信息 | ||
46 | + */ | ||
47 | + public static void debug(String str, Object... args) { | ||
48 | + debug(LogTypeEnum.DEFAULT, str, args); | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * 使用默认的文件记录info信息 | ||
53 | + * | ||
54 | + * @param str 日志信息 | ||
55 | + */ | ||
56 | + public static void info(String str, Object... args) { | ||
57 | + info(LogTypeEnum.DEFAULT, str, args); | ||
58 | + } | ||
59 | + | ||
60 | + /** | ||
61 | + * 使用默认的文件记录warn信息 | ||
62 | + * | ||
63 | + * @param str 日志信息 | ||
64 | + */ | ||
65 | + public static void warn(String str, Object... args) { | ||
66 | + warn(LogTypeEnum.DEFAULT, str, args); | ||
67 | + } | ||
68 | + | ||
69 | + /** | ||
70 | + * 使用默认的文件记录error信息 | ||
71 | + * | ||
72 | + * @param str 日志信息 | ||
73 | + */ | ||
74 | + public static void error(Throwable e, String str, Object... args) { | ||
75 | + error(LogTypeEnum.DEFAULT, e, str, args); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * 记录运行期错误信息 | ||
80 | + * | ||
81 | + * @param e | ||
82 | + */ | ||
83 | + public static void execption(Throwable e) { | ||
84 | + error(LogTypeEnum.EXCEPTION, getExceptionTrace(e)); | ||
85 | + } | ||
86 | + | ||
87 | + /** | ||
88 | + * 打印错误信息 | ||
89 | + * | ||
90 | + * @param e | ||
91 | + * @return | ||
92 | + */ | ||
93 | + public static String getExceptionTrace(Throwable e) { | ||
94 | + if (e != null) { | ||
95 | + StringWriter sw = new StringWriter(); | ||
96 | + PrintWriter pw = new PrintWriter(sw); | ||
97 | + e.printStackTrace(pw); | ||
98 | + return sw.toString(); | ||
99 | + } else | ||
100 | + return null; | ||
101 | + } | ||
102 | + | ||
103 | + public static Logger getLog(LogTypeEnum type) { | ||
104 | + if (logMap.get(type) == null) { | ||
105 | + return LoggerFactory.getLogger(LogHelper.class); | ||
106 | + } else { | ||
107 | + return logMap.get(type); | ||
108 | + } | ||
109 | + } | ||
110 | + | ||
111 | + /** | ||
112 | + * 日志消息占位符形式的替换,按照传入参数依次替换"{}" | ||
113 | + * | ||
114 | + * @param str 带占位符的日志消息 | ||
115 | + * @param args 需要被替换的参数,除了字符串和基本类型的对象形式外,其他类型需要自己实现toString方法 | ||
116 | + * @return | ||
117 | + */ | ||
118 | + public static <T extends Object> String replace(String str, T... args) { | ||
119 | + if (str == null) { | ||
120 | + return addLogbusinessId(null); | ||
121 | + } | ||
122 | + if (args == null || args.length < 1) { | ||
123 | + return addLogbusinessId(str.replaceAll("\\{\\}", " null")); | ||
124 | + } | ||
125 | + StringBuilder builder = new StringBuilder(str); | ||
126 | + int start = builder.indexOf("{"); | ||
127 | + int end = builder.indexOf("}", start); | ||
128 | + for (Object arg : args) { | ||
129 | + if (start == -1) { | ||
130 | + break; | ||
131 | + } | ||
132 | + if (arg == null) { | ||
133 | + arg = "null"; | ||
134 | + } | ||
135 | + builder.replace(start, end + 1, arg.toString()); | ||
136 | + start = start + arg.toString().length(); | ||
137 | + start = builder.indexOf("{", start); | ||
138 | + end = builder.indexOf("}", start); | ||
139 | + } | ||
140 | + return addLogbusinessId(builder.toString()); | ||
141 | + } | ||
142 | + | ||
143 | + /** | ||
144 | + * 记录DEBUG信息 | ||
145 | + * | ||
146 | + * @param type 日志业务类型 | ||
147 | + * @param str | ||
148 | + */ | ||
149 | + public static void debug(LogTypeEnum type, String str, Object... args) { | ||
150 | + Logger log = getLog(type); | ||
151 | + if (log.isDebugEnabled()) { | ||
152 | + String msg = replace(str, args); | ||
153 | + log.debug(msg); | ||
154 | + } | ||
155 | + } | ||
156 | + | ||
157 | + /** | ||
158 | + * 记录INFO信息 | ||
159 | + * | ||
160 | + * @param type 日志业务类型 | ||
161 | + * @param str | ||
162 | + */ | ||
163 | + public static void info(LogTypeEnum type, String str, Object... args) { | ||
164 | + Logger log = getLog(type); | ||
165 | + if (log.isInfoEnabled()) { | ||
166 | + String msg = replace(str, args); | ||
167 | + log.info(msg); | ||
168 | + } | ||
169 | + } | ||
170 | + | ||
171 | + /** | ||
172 | + * 记录warn信息 | ||
173 | + * | ||
174 | + * @param type 日志业务类型 | ||
175 | + * @param str | ||
176 | + */ | ||
177 | + public static void warn(LogTypeEnum type, String str, Object... args) { | ||
178 | + Logger log = getLog(type); | ||
179 | + if (log.isWarnEnabled()) { | ||
180 | + String msg = replace(str, args); | ||
181 | + log.warn(msg); | ||
182 | + } | ||
183 | + } | ||
184 | + | ||
185 | + /** | ||
186 | + * 记录error信息 | ||
187 | + * | ||
188 | + * @param type 日志业务类型 | ||
189 | + * @param str | ||
190 | + */ | ||
191 | + public static void error(LogTypeEnum type, String str, Object... args) { | ||
192 | + Logger log = getLog(type); | ||
193 | + if (log.isErrorEnabled()) { | ||
194 | + String msg = replace(str, args); | ||
195 | + log.error(msg); | ||
196 | + } | ||
197 | + } | ||
198 | + | ||
199 | + /** | ||
200 | + * 记录error信息 | ||
201 | + * | ||
202 | + * @param type 日志业务类型 | ||
203 | + * @param str | ||
204 | + */ | ||
205 | + public static void error(LogTypeEnum type, Throwable e, String str, | ||
206 | + Object... args) { | ||
207 | + Logger log = getLog(type); | ||
208 | + if (log.isErrorEnabled()) { | ||
209 | + String msg = replace(str, args); | ||
210 | + log.error(msg, e); | ||
211 | + } | ||
212 | + } | ||
213 | + | ||
214 | + public static void main(String[] args) { | ||
215 | + LogHelper.debug(LogTypeEnum.DEFAULT, "aaaa"); | ||
216 | + System.out.println(); | ||
217 | + } | ||
218 | +} |
titan-api/src/main/java/com/dili/titan/common/log/LogTypeEnum.java
0 → 100755
1 | +package com.dili.titan.common.log; | ||
2 | + | ||
3 | +import org.apache.commons.lang.StringUtils; | ||
4 | +import org.slf4j.Logger; | ||
5 | + | ||
6 | +/** | ||
7 | + * 日志的业务类型,对重要的业务日志需要在这里定义类型 | ||
8 | + * | ||
9 | + * @author dingjun | ||
10 | + */ | ||
11 | +public enum LogTypeEnum { | ||
12 | + DEFAULT("DEFAULT", "默认"), | ||
13 | + PRODUCT("TITAN_PRODUCT", "商品"), | ||
14 | + CATEGORY("TITAN_CATEGORY", "类目"), | ||
15 | + ATTRIBUTE("TITAN_ATTRIBUTE", "属性"), | ||
16 | + COMMENT("TITAN_COMMENT", "评论"), | ||
17 | + AUTH("TITAN_AUTH", "商品认证"), | ||
18 | + SUPPLY("TITAN_SUPPLY", "供应信息"), | ||
19 | + PURCHASE("TITAN_PURCHASE", "求购信息"), | ||
20 | + PRESALE("TITAN_PRESALE", "预售信息"), | ||
21 | + INDEX_CATEGORY("INDEX_CATEGORY", "指数类目"), | ||
22 | + STOCK("TITAN_STOCK", "库存"), | ||
23 | + PRODUCT_TP("TITAN_SUPPLIER", "供应商商品"), | ||
24 | + EXCEPTION("EXCEPTION", "运行错误"); | ||
25 | + | ||
26 | + private String key; | ||
27 | + private String value; | ||
28 | + | ||
29 | + LogTypeEnum() { | ||
30 | + } | ||
31 | + | ||
32 | + LogTypeEnum(String key, String value) { | ||
33 | + this.key = key; | ||
34 | + this.value = value; | ||
35 | + } | ||
36 | + | ||
37 | + public static String getValue(String key) { | ||
38 | + for (LogTypeEnum ft : LogTypeEnum.values()) { | ||
39 | + if (ft.getKey().equals(key)) { | ||
40 | + return ft.getValue(); | ||
41 | + } | ||
42 | + } | ||
43 | + return null; | ||
44 | + } | ||
45 | + | ||
46 | + public String getKey() { | ||
47 | + return key; | ||
48 | + } | ||
49 | + | ||
50 | + public String getValue() { | ||
51 | + return value; | ||
52 | + } | ||
53 | + | ||
54 | + public Logger getLog() { | ||
55 | + return LogHelper.getLog(this); | ||
56 | + } | ||
57 | + /** | ||
58 | + * 增加日志打印calss信息----暂时未用 | ||
59 | + * @param str | ||
60 | + * @return | ||
61 | + */ | ||
62 | + public static String getClassAndlin(String str) { | ||
63 | + if (StringUtils.isEmpty(str)) { | ||
64 | + return str; | ||
65 | + } | ||
66 | + StackTraceElement stack[] = Thread.currentThread().getStackTrace(); | ||
67 | + boolean boo = false; | ||
68 | + for (StackTraceElement ste : stack) { | ||
69 | + if ((ste.getFileName().indexOf("LogTypeEnum.java")) != -1) { | ||
70 | + boo = true; | ||
71 | + } else if (boo) { | ||
72 | + return new StringBuffer(MarkConstant.LEFT_BRACKET).append(ste.getFileName()).append( | ||
73 | + MarkConstant.SPLIT_CODE) | ||
74 | + .append(ste.getLineNumber()).append(MarkConstant.RIGHT_BRACKET).append( | ||
75 | + MarkConstant.BLANK).append(str).toString(); | ||
76 | + } | ||
77 | + } | ||
78 | + return str; | ||
79 | + } | ||
80 | + | ||
81 | +} |
titan-api/src/main/java/com/dili/titan/common/log/MarkConstant.java
0 → 100755
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-api/src/main/java/com/dili/titan/common/tools/DateUtils.java
0 → 100755
1 | +package com.dili.titan.common.tools; | ||
2 | + | ||
3 | +import org.slf4j.Logger; | ||
4 | +import org.slf4j.LoggerFactory; | ||
5 | + | ||
6 | +import java.text.SimpleDateFormat; | ||
7 | +import java.util.Date; | ||
8 | + | ||
9 | +/** | ||
10 | + * 日期工具类 | ||
11 | + * | ||
12 | + * @author dev-center | ||
13 | + * @since 2014-05-10 | ||
14 | + */ | ||
15 | +public class DateUtils { | ||
16 | + private final static Logger LOGGER = LoggerFactory.getLogger(DateUtils.class); | ||
17 | + | ||
18 | + public static long getServerTime() { | ||
19 | + return System.currentTimeMillis(); | ||
20 | + } | ||
21 | + | ||
22 | + /** | ||
23 | + * 格式化日期,默认返回yyyy-MM-dd HH:mm:ss | ||
24 | + * | ||
25 | + * @param date | ||
26 | + * @return | ||
27 | + */ | ||
28 | + public static String format(Date date) { | ||
29 | + return format(date, "yyyy-MM-dd HH:mm:ss"); | ||
30 | + } | ||
31 | + | ||
32 | + /** | ||
33 | + * 格式化显示当前日期 | ||
34 | + * | ||
35 | + * @param format | ||
36 | + * @return | ||
37 | + */ | ||
38 | + public static String format(String format) { | ||
39 | + return format(new Date(), format); | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * 日期格式化 | ||
44 | + * | ||
45 | + * @param date | ||
46 | + * @param format | ||
47 | + * @return | ||
48 | + */ | ||
49 | + public static String format(Date date, String format) { | ||
50 | + try { | ||
51 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | ||
52 | + return sdf.format(date); | ||
53 | + } catch (Exception e) { | ||
54 | + LOGGER.warn("日期格式化失败.{}", e.getMessage()); | ||
55 | + } | ||
56 | + return null; | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * 时间格式化, 传入毫秒 | ||
61 | + * | ||
62 | + * @param time | ||
63 | + * @return | ||
64 | + */ | ||
65 | + public static String dateFormat(long time) { | ||
66 | + return format(new Date(time), "yyyy-MM-dd HH:mm:ss"); | ||
67 | + } | ||
68 | + | ||
69 | +} |
titan-api/src/main/java/com/dili/titan/common/tools/NullTool.java
0 → 100755
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 | + * Tool for working with <code>null</code> in Velocity templates. | ||
23 | + * It provides a method to set a VTL reference back to <code>null</code>. | ||
24 | + * Also provides methods to check if a VTL reference is <code>null</code> or not. | ||
25 | + * <p> | ||
26 | + * NOTE: These examples assume you have placed an | ||
27 | + * instance of the current context within itself as 'ctx'. | ||
28 | + * And, of course, the NullTool is assumed to be available as 'null'. | ||
29 | + * </p> | ||
30 | + * <p><pre> | ||
31 | + * Example uses: | ||
32 | + * $foo -> bar | ||
33 | + * $null.isNull($foo) -> false | ||
34 | + * $null.isNotNull($foo) -> true | ||
35 | + * | ||
36 | + * $null.setNull($ctx, "foo") | ||
37 | + * $foo -> $foo (null) | ||
38 | + * $null.isNull($foo) -> true | ||
39 | + * $null.isNotNull($foo) -> false | ||
40 | + * | ||
41 | + * $null.set($ctx, $foo, "hoge") | ||
42 | + * $foo -> hoge | ||
43 | + * $null.set($ctx, $foo, $null.null) | ||
44 | + * $foo -> $foo (null) | ||
45 | + * </pre></p> | ||
46 | + * | ||
47 | + * <p>This tool is entirely threadsafe, and has no instance members. | ||
48 | + * It may be used in any scope (request, session, or application). | ||
49 | + * </p> | ||
50 | + * | ||
51 | + * @author <a href="mailto:shinobu@ieee.org">Shinobu Kawai</a> | ||
52 | + * @version $Id: $ | ||
53 | + */ | ||
54 | +public class NullTool | ||
55 | +{ | ||
56 | + | ||
57 | + /** | ||
58 | + * Default constructor. | ||
59 | + */ | ||
60 | + public NullTool() | ||
61 | + { | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Sets the given VTL reference back to <code>null</code>. | ||
66 | + * @param context the current Context | ||
67 | + * @param key the VTL reference to set back to <code>null</code>. | ||
68 | + */ | ||
69 | + public void setNull(Context context, String key) | ||
70 | + { | ||
71 | + if (this.isNull(context)) | ||
72 | + { | ||
73 | + return; | ||
74 | + } | ||
75 | + context.remove(key); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Sets the given VTL reference to the given value. | ||
80 | + * If the value is <code>null</code>, | ||
81 | + * the VTL reference is set to <code>null</code>. | ||
82 | + * @param context the current Context | ||
83 | + * @param key the VTL reference to set. | ||
84 | + * @param value the value to set the VTL reference to. | ||
85 | + */ | ||
86 | + public void set(Context context, String key, Object value) | ||
87 | + { | ||
88 | + if (this.isNull(context)) | ||
89 | + { | ||
90 | + return; | ||
91 | + } | ||
92 | + if (this.isNull(value)) | ||
93 | + { | ||
94 | + this.setNull(context, key); | ||
95 | + return; | ||
96 | + } | ||
97 | + context.put(key, value); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * Checks if a VTL reference is <code>null</code>. | ||
102 | + * @param object the VTL reference to check. | ||
103 | + * @return <code>true</code> if the VTL reference is <code>null</code>, | ||
104 | + * <code>false</code> if otherwise. | ||
105 | + */ | ||
106 | + public boolean isNull(Object object) | ||
107 | + { | ||
108 | + return object == null; | ||
109 | + } | ||
110 | + | ||
111 | + /** | ||
112 | + * Checks if a VTL reference is not <code>null</code>. | ||
113 | + * @param object the VTL reference to check. | ||
114 | + * @return <code>true</code> if the VTL reference is not <code>null</code>, | ||
115 | + * <code>false</code> if otherwise. | ||
116 | + */ | ||
117 | + public boolean isNotNull(Object object) | ||
118 | + { | ||
119 | + return !this.isNull(object); | ||
120 | + } | ||
121 | + | ||
122 | + /** | ||
123 | + * A convinient method which returns <code>null</code>. | ||
124 | + * Actually, this tool will work the same without this method, | ||
125 | + * because Velocity treats non-existing methods as null. :) | ||
126 | + * @return <code>null</code> | ||
127 | + */ | ||
128 | + public Object getNull() | ||
129 | + { | ||
130 | + return null; | ||
131 | + } | ||
132 | + | ||
133 | +} |
titan-api/src/main/java/com/dili/titan/common/tools/RegexUtils.java
0 → 100755
1 | +package com.dili.titan.common.tools; | ||
2 | + | ||
3 | +import java.util.regex.Matcher; | ||
4 | +import java.util.regex.Pattern; | ||
5 | + | ||
6 | +public class RegexUtils { | ||
7 | + | ||
8 | + /** | ||
9 | + * 合法的属性名字正则表达式 | ||
10 | + */ | ||
11 | + public final static String VALID_ATTRIBUTE_NAME_REGEX = "^[a-zA-Z\\+\\/&\u4e00-\u9fa5]+$"; | ||
12 | + | ||
13 | + /** | ||
14 | + * 检验字符串师傅匹配正则表达式 | ||
15 | + * @param regex | ||
16 | + * @param content | ||
17 | + * @return | ||
18 | + * @createTime 2014年6月3日 上午10:06:45 | ||
19 | + * @author dili-guwenwu | ||
20 | + */ | ||
21 | + public static boolean match(String regex, String content) { | ||
22 | + Pattern pattern = Pattern.compile(regex); | ||
23 | + Matcher matcher = pattern.matcher(content); | ||
24 | + return matcher.find(); | ||
25 | + } | ||
26 | +} |
titan-api/src/main/java/com/dili/titan/common/tools/Tools.java
0 → 100755
1 | +package com.dili.titan.common.tools; | ||
2 | + | ||
3 | +import java.math.BigDecimal; | ||
4 | +import java.text.ParseException; | ||
5 | +import java.text.SimpleDateFormat; | ||
6 | +import java.util.*; | ||
7 | +import java.util.regex.Matcher; | ||
8 | +import java.util.regex.Pattern; | ||
9 | +/** | ||
10 | + * <B>Description</B> 工具类 | ||
11 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | ||
12 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
13 | + * <B>Company</B> 地利集团 | ||
14 | + * @createTime 2014年6月25日 下午2:15:09 | ||
15 | + * @author yangjianjun | ||
16 | + */ | ||
17 | +public class Tools { | ||
18 | + /** | ||
19 | + * this method is 判断是否是ASCII编码 | ||
20 | + * @param string | ||
21 | + * @return | ||
22 | + * @createTime 2014年6月25日 下午2:14:50 | ||
23 | + * @author yangjianjun | ||
24 | + */ | ||
25 | + public static boolean isASCIIEncoded(String string) { | ||
26 | + if(string == null){ | ||
27 | + string =""; | ||
28 | + } | ||
29 | + return !Pattern.compile("[^\\x00-\\xff]").matcher(string).find(); | ||
30 | + } | ||
31 | + | ||
32 | + | ||
33 | + /** | ||
34 | + * this method is 获取字符串长度,一个中文占2个长度 | ||
35 | + * @param string | ||
36 | + * @return | ||
37 | + * @createTime 2014年6月25日 下午2:14:33 | ||
38 | + * @author yangjianjun | ||
39 | + */ | ||
40 | + public static int getLength(String string) { | ||
41 | + if(string == null){ | ||
42 | + string = ""; | ||
43 | + } | ||
44 | + // String reg = "[^\\x00-\\x7f]"; | ||
45 | + String reg = "[^\\x00-\\xff]"; | ||
46 | + Pattern pattern =Pattern.compile(reg); | ||
47 | + Matcher mathcher = pattern.matcher(string); | ||
48 | + if(mathcher.find()){ | ||
49 | + return string.length()*2; | ||
50 | + } | ||
51 | + return string.length(); | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * 时间格式化 | ||
56 | + * @author yangjianjun | ||
57 | + * @creaetime Jul 18, 2012 7:22:29 PM | ||
58 | + * @param date date | ||
59 | + * @param p parameter | ||
60 | + * @return dateFormat | ||
61 | + */ | ||
62 | + public static String formatDateTime(Date date, int p) { | ||
63 | + String pattern = "yyyy-MM-dd HH:mm:ss"; | ||
64 | + switch (p) { | ||
65 | + case 1: | ||
66 | + pattern = "yyyy-MM-dd"; | ||
67 | + break; | ||
68 | + case 2: | ||
69 | + pattern = "yyyy-MM-dd HH:mm:ss"; | ||
70 | + break; | ||
71 | + case 3: | ||
72 | + pattern = "yyyy-MM-dd HH:mm:ss.SSS"; | ||
73 | + break; | ||
74 | + case 4: | ||
75 | + pattern = "yyyy-MM"; | ||
76 | + break; | ||
77 | + case 5: | ||
78 | + pattern = "MM-dd"; | ||
79 | + break; | ||
80 | + case 6: | ||
81 | + pattern = "HH:mm:ss"; | ||
82 | + break; | ||
83 | + case 7: | ||
84 | + pattern = "HH:mm"; | ||
85 | + break; | ||
86 | + case 8: | ||
87 | + pattern = "MM-dd HH:mm:ss"; | ||
88 | + break; | ||
89 | + case 9: | ||
90 | + pattern = "MM-dd HH:mm"; | ||
91 | + break; | ||
92 | + case 10: | ||
93 | + pattern = "yyyyMMddHHmmssSSS"; | ||
94 | + break; | ||
95 | + default: | ||
96 | + break; | ||
97 | + } | ||
98 | + return new SimpleDateFormat(pattern).format(date); | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * this method is 将字符串转化为日期格式 | ||
103 | + * @param time | ||
104 | + * @param type | ||
105 | + * @return | ||
106 | + * @throws ParseException | ||
107 | + * @createTime 2014年6月25日 下午2:14:09 | ||
108 | + * @author yangjianjun | ||
109 | + */ | ||
110 | + public static Date stringToDate(String time,int type) throws Exception{ | ||
111 | + SimpleDateFormat simple=null; | ||
112 | + switch (type) { | ||
113 | + case 1: | ||
114 | + simple=new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
115 | + break; | ||
116 | + case 2: | ||
117 | + simple=new SimpleDateFormat("yyyy-MM-dd"); | ||
118 | + break; | ||
119 | + default: | ||
120 | + break; | ||
121 | + } | ||
122 | + if(simple == null ){ | ||
123 | + throw new Exception("参数有误!"); | ||
124 | + } | ||
125 | + Date date = simple.parse(time); | ||
126 | + return date; | ||
127 | + } | ||
128 | + | ||
129 | + /** | ||
130 | + * this method is 验证某个对象是否为空 | ||
131 | + * @param obj | ||
132 | + * @return | ||
133 | + * @createTime 2014年6月25日 下午2:13:25 | ||
134 | + * @author yangjianjun | ||
135 | + */ | ||
136 | + public static boolean objectIsNotNull(Object obj) { | ||
137 | + return (null != obj) ? true : false; | ||
138 | + } | ||
139 | + | ||
140 | + /** | ||
141 | + * this method is 判断某一个集合对象是否为空 | ||
142 | + * @param list | ||
143 | + * @return | ||
144 | + * @createTime 2014年6月25日 下午2:11:46 | ||
145 | + * @author yangjianjun | ||
146 | + */ | ||
147 | + public static <T> boolean checkListNotNull(List<T> list){ | ||
148 | + if(list == null || list.size() < 1){ | ||
149 | + return true; | ||
150 | + } | ||
151 | + return false; | ||
152 | + } | ||
153 | + | ||
154 | + /** | ||
155 | + * 判断一个字符串是否在另一个字符串中存在 | ||
156 | + * @author yangjianjun | ||
157 | + * @creaetime Nov 26, 2012 4:01:19 PM | ||
158 | + * @param str0 字符串规则 | ||
159 | + * @param str1 要检查的字符串 | ||
160 | + * @return boolean | ||
161 | + */ | ||
162 | + public static boolean isExistString(String str0,String str1){ | ||
163 | + int indexOf=str0.indexOf(str1); | ||
164 | + if(indexOf>=0){ | ||
165 | + return true; | ||
166 | + }else{ | ||
167 | + return false; | ||
168 | + } | ||
169 | + } | ||
170 | + /** | ||
171 | + * 计算某个时间到某个时间的时差等信息 | ||
172 | + * @author yangjianjun | ||
173 | + * @creaetime Nov 28, 2014 3:16:21 PM | ||
174 | + * @param startTime beginTime | ||
175 | + * @param endTime endTime | ||
176 | + * @param format temple | ||
177 | + * @param str 小时 | ||
178 | + * @return 时差 | ||
179 | + * @throws ParseException ParseException | ||
180 | + */ | ||
181 | + public static Long dateDiff(String startTime, String endTime, | ||
182 | + String format, String str) throws ParseException { | ||
183 | + // 按照传入的格式生成一个simpledateformate对象 | ||
184 | + SimpleDateFormat sd = new SimpleDateFormat(format); | ||
185 | + long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数 | ||
186 | + long nh = 1000 * 60 * 60;// 一小时的毫秒数 | ||
187 | + long nm = 1000 * 60;// 一分钟的毫秒数 | ||
188 | + long ns = 1000;// 一秒钟的毫秒数 | ||
189 | + long diff; | ||
190 | + long day = 0; | ||
191 | + long hour = 0; | ||
192 | + long min = 0; | ||
193 | + long sec = 0; | ||
194 | + // 获得两个时间的毫秒时间差异 | ||
195 | + diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime(); | ||
196 | + day = diff / nd;// 计算差多少天 | ||
197 | + hour = diff % nd / nh + day * 24;// 计算差多少小时 | ||
198 | + min = diff % nd % nh / nm + day * 24 * 60;// 计算差多少分钟 | ||
199 | + sec = diff % nd % nh % nm / ns;// 计算差多少秒 | ||
200 | + // 输出结果 | ||
201 | + System.out.println("时间相差:" + day + "天" + (hour - day * 24) + "小时" | ||
202 | + + (min - day * 24 * 60) + "分钟" + sec + "秒。"); | ||
203 | + System.out.println("hour=" + hour + ",min=" + min); | ||
204 | + if (str.equalsIgnoreCase("h")) { | ||
205 | + return hour; | ||
206 | + } else { | ||
207 | + return min; | ||
208 | + } | ||
209 | + } | ||
210 | + /** | ||
211 | + * 计算结束时间到开始时间的秒数 | ||
212 | + * @author yangjianjun | ||
213 | + * @createtime 2014年6月25日 下午2:09:10 | ||
214 | + * @param startTime | ||
215 | + * @param endTime | ||
216 | + * @param format | ||
217 | + * @return | ||
218 | + */ | ||
219 | + public static Long dateDiff (String startTime, String endTime, | ||
220 | + String format){ | ||
221 | + SimpleDateFormat sf = new SimpleDateFormat(format); | ||
222 | + long time=-1; | ||
223 | + try { | ||
224 | + time=sf.parse(endTime).getTime()- sf.parse(startTime).getTime(); | ||
225 | + } catch (ParseException e) { | ||
226 | + // TODO Auto-generated catch block | ||
227 | + } | ||
228 | + return time/1000; | ||
229 | + } | ||
230 | + /** | ||
231 | + * this method is 除法结果保留两位小数并按照第二位小数四舍五入 | ||
232 | + * @param divisor 除数 | ||
233 | + * @param dividend 被除数 | ||
234 | + * @param k 保留小数的位数及四舍五入的位数 | ||
235 | + * @return double数值 | ||
236 | + * @createTime 2014年6月25日 下午2:09:10 | ||
237 | + * @author yangjianjun | ||
238 | + */ | ||
239 | + public static double getRoundDecimal(long divisor,long dividend,int k) { | ||
240 | + BigDecimal dec1=new BigDecimal(divisor); | ||
241 | + BigDecimal dec2=new BigDecimal(dividend); | ||
242 | + return dec1.divide(dec2, k,BigDecimal.ROUND_HALF_UP).doubleValue(); | ||
243 | + } | ||
244 | + | ||
245 | + | ||
246 | + /** | ||
247 | + * this method is 根据秒数求出时间 | ||
248 | + * @param time | ||
249 | + * @return | ||
250 | + * @createTime 2014年6月25日 下午2:09:51 | ||
251 | + * @author yangjianjun | ||
252 | + */ | ||
253 | + public static String paserTime(String time){ | ||
254 | + System.setProperty("user.timezone", "Asia/Shanghai"); | ||
255 | + TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); | ||
256 | + TimeZone.setDefault(tz); | ||
257 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
258 | + String times = format.format(new Date(Long.parseLong(time) * 1000L)); | ||
259 | +// System.out.print("日期为:" + times); | ||
260 | + return times; | ||
261 | + } | ||
262 | + | ||
263 | + /** | ||
264 | + * this method is 根据时间求出秒数 | ||
265 | + * @param date | ||
266 | + * @return | ||
267 | + * @createTime 2014年6月25日 下午2:10:08 | ||
268 | + * @author yangjianjun | ||
269 | + */ | ||
270 | + public static long paserSecond(Date date){ | ||
271 | + long dates = date.getTime()/1000L; | ||
272 | + return dates; | ||
273 | + } | ||
274 | + /** | ||
275 | + * this method is 根据实际和天数计算出最新时间 | ||
276 | + * @param dates 当前时间 | ||
277 | + * @param day 当前天数 | ||
278 | + * @return 最新时间 | ||
279 | + * @createTime 2014年7月10日 上午11:11:51 | ||
280 | + * @author yangjianjun | ||
281 | + */ | ||
282 | + public static Date getBeforeAfterDate(Date dates, int day) { | ||
283 | + Calendar cal = new GregorianCalendar(); | ||
284 | + cal.setTime(dates); | ||
285 | + int Year = cal.get(Calendar.YEAR); | ||
286 | + int Month = cal.get(Calendar.MONTH); | ||
287 | + int Day = cal.get(Calendar.DAY_OF_MONTH); | ||
288 | + int NewDay = Day + day; | ||
289 | + cal.set(Calendar.YEAR, Year); | ||
290 | + cal.set(Calendar.MONTH, Month); | ||
291 | + cal.set(Calendar.DAY_OF_MONTH, NewDay); | ||
292 | + return new Date(cal.getTimeInMillis()); | ||
293 | + } | ||
294 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/ListCovertMapUtils.java
0 → 100755
1 | +package com.dili.titan.common.utils; | ||
2 | + | ||
3 | +import com.dili.titan.common.MapKey; | ||
4 | +import org.apache.commons.collections.CollectionUtils; | ||
5 | + | ||
6 | +import java.lang.reflect.Field; | ||
7 | +import java.util.HashMap; | ||
8 | +import java.util.List; | ||
9 | +import java.util.Map; | ||
10 | + | ||
11 | +/** | ||
12 | + * <p> | ||
13 | + * Title: 〈标题〉 | ||
14 | + * </p> | ||
15 | + * <p> | ||
16 | + * Description: 〈描述〉 | ||
17 | + * </p> | ||
18 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | ||
19 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
20 | + * <B>Company</B> 地利集团 | ||
21 | + * <p> | ||
22 | + * CreateTime:2015/4/1 | ||
23 | + * </p> | ||
24 | + * | ||
25 | + * @author gongsz | ||
26 | + */ | ||
27 | +public class ListCovertMapUtils<KEY, T> { | ||
28 | + | ||
29 | + private static ListCovertMapUtils instance; | ||
30 | + | ||
31 | + private ListCovertMapUtils() { | ||
32 | + } | ||
33 | + | ||
34 | + public static ListCovertMapUtils getInstance() { | ||
35 | + if (instance == null) { | ||
36 | + instance = new ListCovertMapUtils(); | ||
37 | + } | ||
38 | + return instance; | ||
39 | + } | ||
40 | + | ||
41 | + public Map<KEY, T> covertList(List<T> list) { | ||
42 | + if (CollectionUtils.isEmpty(list)) { | ||
43 | + return null; | ||
44 | + } | ||
45 | + Map<KEY, T> map = new HashMap<KEY, T>(); | ||
46 | + for (T obj : list) { | ||
47 | + boolean isBreak = false; | ||
48 | + for (Class<?> clazz = obj.getClass(); clazz != Object.class; clazz = clazz | ||
49 | + .getSuperclass()) { | ||
50 | + Field[] fields = clazz.getDeclaredFields(); | ||
51 | + if (fields.length == 0) { | ||
52 | + continue; | ||
53 | + } | ||
54 | + for (Field field : fields) { | ||
55 | + field.setAccessible(true); | ||
56 | + MapKey annotation = field.getAnnotation(MapKey.class); | ||
57 | + if (annotation != null) { | ||
58 | + try { | ||
59 | + map.put((KEY) field.get(obj), obj); | ||
60 | + isBreak=true; | ||
61 | + break; | ||
62 | + } catch (Exception e) { | ||
63 | + | ||
64 | + } | ||
65 | + } | ||
66 | + } | ||
67 | + if(isBreak){ | ||
68 | + break; | ||
69 | + } | ||
70 | + } | ||
71 | + | ||
72 | + } | ||
73 | + return map; | ||
74 | + } | ||
75 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/SkuUtil.java
0 → 100755
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 | + * @createTime 2014年5月26日 下午11:15:12 | ||
23 | + * @author celine | ||
24 | + */ | ||
25 | +public class SkuUtil { | ||
26 | + | ||
27 | + private final static Logger logger = Logger.getLogger(SkuUtil.class); | ||
28 | + private final static int ORI_RADIX = 11;// 原始SKU进制 | ||
29 | + private final static int SKU_RADIX = 62; | ||
30 | + public final static String SPLIT = ":"; | ||
31 | + | ||
32 | + /** | ||
33 | + * 将编码后不带版本号的skuEncWithoutVersion和version编码成新的SKU | ||
34 | + * @param skuEncWithoutVersion pid+attVal编码后的sku | ||
35 | + * @param version sku版本号 | ||
36 | + * @createTime 2014年6月18日 下午8:28:42 | ||
37 | + */ | ||
38 | + public static String encode(String skuEncWithoutVersion, Integer version) { | ||
39 | + String skuOri = decode(skuEncWithoutVersion, false); | ||
40 | + return SkuUtil.encode(version + SPLIT + skuOri); | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * 将带版本号的sku转换成不带版本号的SKU | ||
45 | + * @param encSku | ||
46 | + * @return | ||
47 | + */ | ||
48 | + public static String covertVersionSku(String encSku){ | ||
49 | + String sku = decode(encSku,true); | ||
50 | + return encode(sku); | ||
51 | + } | ||
52 | + /** | ||
53 | + * 生成商品由属性值ID拼接成的SKU字符串,attrMap为空时,默认为没有销售属性,返回0 | ||
54 | + * | ||
55 | + * @param attrMap 属性项-属性值的Map | ||
56 | + * @return | ||
57 | + * @createTime 2014年6月18日 下午2:59:24 | ||
58 | + * @author celine | ||
59 | + */ | ||
60 | + public static String getSkuByAttrId(TreeMap<Long, Long> attrMap, Long pid) { | ||
61 | + if (attrMap == null || attrMap.size() == 0) { | ||
62 | + return pid == null ? null : pid + SPLIT + "0"; | ||
63 | + } | ||
64 | + Set<Entry<Long, Long>> entries = attrMap.entrySet(); | ||
65 | + | ||
66 | + if (pid != null) { | ||
67 | + StringBuilder sb = new StringBuilder(); | ||
68 | + sb.append(pid + SPLIT); | ||
69 | + int i = 0; | ||
70 | + for (Entry<Long, Long> entry : entries) { | ||
71 | + i++; | ||
72 | + if (i < entries.size()) { | ||
73 | + sb.append(entry.getValue() + SPLIT); | ||
74 | + } else { | ||
75 | + sb.append(entry.getValue()); | ||
76 | + } | ||
77 | + } | ||
78 | + return sb.toString(); | ||
79 | + } | ||
80 | + return null; | ||
81 | + | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * 解析sku中的版本号 | ||
86 | + * @param encSku 编码后的sku | ||
87 | + * @return | ||
88 | + * @throws TitanError | ||
89 | + * @createTime 2014年6月18日 下午6:52:32 | ||
90 | + */ | ||
91 | + public static Integer getVersion(String encSku) throws TitanError { | ||
92 | + try { | ||
93 | + BigInteger bi = sixtytwoToTen(encSku); | ||
94 | + String skuDe = tenToM(bi, ORI_RADIX); | ||
95 | + String[] skuSplit = skuDe.split(SPLIT); | ||
96 | + String verStr = skuSplit[0]; | ||
97 | + Integer version = Integer.parseInt(verStr); | ||
98 | + return version; | ||
99 | + } catch (Exception e) { | ||
100 | + throw new TitanError(0, "解析版本号失败"); | ||
101 | + } | ||
102 | + | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * 从带版本号的sku中获取不带版本号的sku | ||
107 | + * @param encSku 编码后的sku,包含版本号 | ||
108 | + * @return 编码后的sku,不带版本号 | ||
109 | + * @throws TitanError | ||
110 | + * @createTime 2014年6月18日 下午6:52:32 | ||
111 | + */ | ||
112 | + public static String getSkuEncWithOutVersion(String encSku) { | ||
113 | + String skuDe = decode(encSku); | ||
114 | + return encode(skuDe); | ||
115 | + | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * 解析sku中的PID | ||
120 | + * @param encSku 编码后的sku | ||
121 | + * @param hasVersion sku中是否包含版本 | ||
122 | + * @return | ||
123 | + * @throws TitanError | ||
124 | + * @createTime 2014年6月18日 下午6:52:32 | ||
125 | + */ | ||
126 | + public static Long getPid(String encSku, boolean hasVersion){ | ||
127 | + String skuDe = decode(encSku, hasVersion); | ||
128 | + String[] skuSplit = skuDe.split(SPLIT); | ||
129 | + String pidStr = skuSplit[0]; | ||
130 | + Long pid = Long.parseLong(pidStr); | ||
131 | + return pid; | ||
132 | + } | ||
133 | + | ||
134 | + /** | ||
135 | + * 解析sku中的商品属性值ID | ||
136 | + * @param encSku 编码后的sku | ||
137 | + * @param hasVersion sku中是否包含版本 | ||
138 | + * @return | ||
139 | + * @throws TitanError | ||
140 | + * @createTime 2014年6月18日 下午6:52:32 | ||
141 | + */ | ||
142 | + public static String getAttrVal(String encSku, boolean hasVersion){ | ||
143 | + String skuDe = decode(encSku, hasVersion); | ||
144 | + return skuDe.substring(skuDe.indexOf(SPLIT) + 1, skuDe.length()); | ||
145 | + } | ||
146 | + | ||
147 | + /** | ||
148 | + * 解析sku中的商品属性值ID | ||
149 | + * @param encSku 编码后的sku | ||
150 | + * @param hasVersion sku中是否包含版本 | ||
151 | + * @return | ||
152 | + * @throws TitanError | ||
153 | + * @createTime 2014年6月18日 下午6:52:32 | ||
154 | + */ | ||
155 | + public static List<Long> getAttrValList(String encSku, boolean hasVersion){ | ||
156 | + String attrvalStr = getAttrVal(encSku, hasVersion); | ||
157 | + if (StringUtils.isEmpty(attrvalStr)) | ||
158 | + return null; | ||
159 | + List<Long> list = new ArrayList<Long>(); | ||
160 | + String[] attrvalIds = attrvalStr.split(SPLIT); | ||
161 | + for (String attrvalId : attrvalIds) { | ||
162 | + list.add(Long.parseLong(attrvalId)); | ||
163 | + } | ||
164 | + return list; | ||
165 | + } | ||
166 | + | ||
167 | + /** | ||
168 | + * 通过sku确定商品的种类 1-第三方商品 2-供应商商品 3-网站商品 | ||
169 | + * @param encSku | ||
170 | + * @param hasVersion sku中是否包含version | ||
171 | + * @return | ||
172 | + * @createTime 2014年6月6日 下午6:28:58 | ||
173 | + * @author celine | ||
174 | + */ | ||
175 | + public static int getProductType(String encSku, boolean hasVersion) { | ||
176 | + String skuDe = decode(encSku, hasVersion); | ||
177 | + String[] skuSplit = skuDe.split(SPLIT); | ||
178 | + if (skuSplit.length > 0) { | ||
179 | + String pidStart = skuSplit[0].substring(0, 1); | ||
180 | + int flag = Integer.parseInt(pidStart); | ||
181 | + return determineStype(flag); | ||
182 | + } | ||
183 | + return 0; | ||
184 | + } | ||
185 | + | ||
186 | + /** | ||
187 | + * 通过sku确定商品的种类 1-第三方商品 2-供应商商品 3-网站商品 | ||
188 | + * @param encSku 编码后的sku,默认包含version | ||
189 | + * @return | ||
190 | + * @createTime 2014年6月6日 下午6:28:58 | ||
191 | + * @author celine | ||
192 | + */ | ||
193 | + public static int getProductType(String encSku) { | ||
194 | + return getProductType(encSku, true); | ||
195 | + } | ||
196 | + | ||
197 | + /** | ||
198 | + * 通过pid确定商品的种类 1-第三方商品 2-供应商商品 3-网站商品 | ||
199 | + * @return | ||
200 | + * @createTime 2014年6月6日 下午6:28:58 | ||
201 | + * @author celine | ||
202 | + */ | ||
203 | + public static int getProductTypeByPid(String pid) { | ||
204 | + if (pid != null && !pid.equals("")) { | ||
205 | + String pidStart = pid.substring(0, 1); | ||
206 | + int flag = Integer.parseInt(pidStart); | ||
207 | + return determineStype(flag); | ||
208 | + } | ||
209 | + return 0; | ||
210 | + } | ||
211 | + | ||
212 | + /** | ||
213 | + * 对原始SKU串进行编码 | ||
214 | + * @param oriStr | ||
215 | + * @return | ||
216 | + * @createTime 2014年5月27日 上午12:19:22 | ||
217 | + * @author celine | ||
218 | + */ | ||
219 | + public static String encode(String oriStr) { | ||
220 | + try { | ||
221 | + BigInteger bi = elevenToTen(oriStr); | ||
222 | + return tenToM(bi, SKU_RADIX); | ||
223 | + } catch (Exception e) { | ||
224 | + logger.error("Encode Error. ", e); | ||
225 | + return null; | ||
226 | + } | ||
227 | + } | ||
228 | + | ||
229 | + /** | ||
230 | + * 将编码后的SKU转换为PID:属性值形式 | ||
231 | + * @param skuEnc 编码后的SKU,包含版本号 | ||
232 | + * @return | ||
233 | + * @createTime 2014年5月27日 上午12:20:17 | ||
234 | + * @author celine | ||
235 | + */ | ||
236 | + public static String decode(String skuEnc) { | ||
237 | + return decode(skuEnc, true); | ||
238 | + } | ||
239 | + | ||
240 | + /** | ||
241 | + * 将编码后的SKU转换为PID:属性值形式 | ||
242 | + * @param skuEnc 编码后的SKU | ||
243 | + * @param hasVersion sku中是否包含sku信息 | ||
244 | + * @return | ||
245 | + * @createTime 2014年5月27日 上午12:20:17 | ||
246 | + * @author celine | ||
247 | + */ | ||
248 | + public static String decode(String skuEnc, boolean hasVersion) { | ||
249 | + try { | ||
250 | + BigInteger bi = sixtytwoToTen(skuEnc); | ||
251 | + String skuOriWithVersion = tenToM(bi, ORI_RADIX); | ||
252 | + if (hasVersion) { | ||
253 | + return skuOriWithVersion.substring(skuOriWithVersion.indexOf(SPLIT) + 1, skuOriWithVersion.length()); | ||
254 | + } | ||
255 | + return skuOriWithVersion; | ||
256 | + } catch (Exception e) { | ||
257 | + logger.error("Decode Error. ", e); | ||
258 | + return null; | ||
259 | + } | ||
260 | + } | ||
261 | + | ||
262 | + /** | ||
263 | + * 将任意进制的数转换为十进制,本系统中用':'作为第十一位, | ||
264 | + * @param s | ||
265 | + * @return | ||
266 | + * @createTime 2014年5月26日 下午10:27:05 | ||
267 | + * @author celine | ||
268 | + */ | ||
269 | + private static BigInteger elevenToTen(String s) throws Exception { | ||
270 | + | ||
271 | + Pattern pattern = Pattern.compile("^[0-9:]+$"); | ||
272 | + Matcher matcher = pattern.matcher(s); | ||
273 | + | ||
274 | + if (matcher.find()) { | ||
275 | + BigInteger oriBi = BigInteger.valueOf(ORI_RADIX); | ||
276 | + BigInteger tmpBi = new BigInteger("0"); | ||
277 | + for (int i = 0; i < s.length(); i++) { | ||
278 | + char tmpC = s.charAt(i); | ||
279 | + int tmp = tmpC - '0'; | ||
280 | + tmpBi = tmpBi.multiply(oriBi).add(BigInteger.valueOf(tmp)); | ||
281 | + } | ||
282 | + return tmpBi; | ||
283 | + } else { | ||
284 | + // 不全为数字和':' | ||
285 | + logger.error("Invalid input " + s); | ||
286 | + throw new Exception("Invalid input " + s); | ||
287 | + } | ||
288 | + } | ||
289 | + | ||
290 | + private static BigInteger sixtytwoToTen(String s) throws Exception { | ||
291 | + Pattern pattern = Pattern.compile("^[0-9a-zA-z]+$"); | ||
292 | + Matcher matcher = pattern.matcher(s); | ||
293 | + | ||
294 | + if (matcher.find()) { | ||
295 | + BigInteger skuBi = BigInteger.valueOf(SKU_RADIX); | ||
296 | + BigInteger tmpBi = new BigInteger("0"); | ||
297 | + for (int i = 0; i < s.length(); i++) { | ||
298 | + char tmpC = s.charAt(i); | ||
299 | + int tmp = convertStringToInt62(tmpC); | ||
300 | + tmpBi = tmpBi.multiply(skuBi).add(BigInteger.valueOf(tmp)); | ||
301 | + } | ||
302 | + return tmpBi; | ||
303 | + } else { | ||
304 | + // 不全为数字和大小写字母 | ||
305 | + throw new Exception("Invalid input " + s); | ||
306 | + } | ||
307 | + } | ||
308 | + | ||
309 | + /** | ||
310 | + * 将十进制转换为十一或六十二 | ||
311 | + * @param bi | ||
312 | + * @param m | ||
313 | + * @createTime 2014年5月26日 下午10:58:20 | ||
314 | + * @author celine | ||
315 | + * @throws Exception | ||
316 | + */ | ||
317 | + private static String tenToM(BigInteger bi, int m) throws Exception { | ||
318 | + StringBuffer bs = new StringBuffer(); | ||
319 | + BigInteger zero = BigInteger.valueOf(0); | ||
320 | + BigInteger targetBi = BigInteger.valueOf(m); | ||
321 | + while (bi.compareTo(zero) > 0) { | ||
322 | + BigInteger mod = bi.mod(targetBi); | ||
323 | + if (m == ORI_RADIX) { | ||
324 | + bs.insert(0, convertIntToString11(mod.intValue())); | ||
325 | + } else if (m == SKU_RADIX) { | ||
326 | + bs.insert(0, convertIntToString62(mod.intValue())); | ||
327 | + } | ||
328 | + bi = bi.divide(targetBi); | ||
329 | + } | ||
330 | + return bs.toString(); | ||
331 | + } | ||
332 | + | ||
333 | + /** | ||
334 | + * 将整数转换为对应62进制的字符 | ||
335 | + * @param i | ||
336 | + * @return | ||
337 | + * @createTime 2014年5月26日 下午11:14:24 | ||
338 | + * @author celine | ||
339 | + * @throws Exception | ||
340 | + */ | ||
341 | + private static char convertIntToString62(int i) throws Exception { | ||
342 | + if (i >= 0 && i <= 9) { | ||
343 | + return (char) (i + '0'); | ||
344 | + } else if (i > 9 && i < 36) { | ||
345 | + return (char) ('a' + i - 10); | ||
346 | + } else if (i >= 36 && i < 62) { | ||
347 | + return (char) ('A' + i - 36); | ||
348 | + } else { | ||
349 | + throw new Exception("Invalid input " + i); | ||
350 | + } | ||
351 | + } | ||
352 | + | ||
353 | + /** | ||
354 | + * 将整数转换为对应11进制的字符 | ||
355 | + * @param i | ||
356 | + * @return | ||
357 | + * @throws Exception | ||
358 | + * @createTime 2014年5月26日 下午11:30:15 | ||
359 | + * @author celine | ||
360 | + */ | ||
361 | + private static char convertIntToString11(int i) throws Exception { | ||
362 | + if (i >= 0 && i <= 10) { | ||
363 | + return (char) (i + '0'); | ||
364 | + } else { | ||
365 | + throw new Exception("Invalid input " + i); | ||
366 | + } | ||
367 | + } | ||
368 | + | ||
369 | + private static int convertStringToInt62(char c) throws Exception { | ||
370 | + if (c >= '0' && c <= '9') { | ||
371 | + return c - '0'; | ||
372 | + } else if (c >= 'a' && c <= 'z') { | ||
373 | + return c - 'a' + 10; | ||
374 | + } else if (c >= 'A' && c <= 'Z') { | ||
375 | + return c - 'A' + 36; | ||
376 | + } else { | ||
377 | + throw new Exception("Invalid input " + c); | ||
378 | + } | ||
379 | + } | ||
380 | + | ||
381 | + /** | ||
382 | + * 确定商品类型 | ||
383 | + * @param flag | ||
384 | + * @return | ||
385 | + * @createTime 2014年6月6日 下午6:40:15 | ||
386 | + * @author celine | ||
387 | + */ | ||
388 | + private static int determineStype(int flag) { | ||
389 | + switch (flag) { | ||
390 | + case 1: | ||
391 | + case 2: | ||
392 | + case 3: | ||
393 | + case 4: | ||
394 | + return ProductStatus.PRODUCT_POP; | ||
395 | + case 5: | ||
396 | + case 6: | ||
397 | + case 7: | ||
398 | + case 8: | ||
399 | + case 9: | ||
400 | + default: | ||
401 | + break; | ||
402 | + } | ||
403 | + return 0; | ||
404 | + } | ||
405 | + | ||
406 | + /** | ||
407 | + * 获取销售类型 | ||
408 | + * @param pid | ||
409 | + * @return | ||
410 | + */ | ||
411 | + public static String getSaleType(Long pid) { | ||
412 | + if (pid >= 1000000000l && pid < 5000000000l) { | ||
413 | + return ProductStatus.SALE_TYPE_POP; | ||
414 | + } else { | ||
415 | + return null; | ||
416 | + } | ||
417 | + } | ||
418 | + public static void main(String[] args) throws Exception{ | ||
419 | +// String [] str={"2t3on7sJ8o","dUFFyuPwZ","2t3on7A9ZX","2t3on7A9ZZ","dUFFyvvqA","dUFFyvvqC","dUFFywbFG","dUFFywbFF","dUFFywbFE"}; | ||
420 | +// String [] str={"8HaxIIqWR","8HaxIIqWT","N0XqBUPp","N0XqBUPr","N0XqC2rJ","N0XqC2rI"}; | ||
421 | +// for(int i=0;i<str.length;i++){ | ||
422 | +// System.out.println(SkuUtil.encode(str[i],1)); | ||
423 | +// } | ||
424 | +// System.out.println(SkuUtil.encode("3orUNksjei",1));8000000021:11:24 | ||
425 | +// System.out.println(SkuUtil.encode("8000000021:-1")); | ||
426 | +// System.out.println(SkuUtil.decode(SkuUtil.encode("Ebrw7sA", 1))); | ||
427 | +// System.out.println(SkuUtil.decode("2t3on6CVif", false)); | ||
428 | +// System.out.println(SkuUtil.encode("2t3on6CVif",123123123)); | ||
429 | +// System.out.println(SkuUtil.decode("1aP75Z99Kmb", true)); | ||
430 | + System.out.println(SkuUtil.getVersion("9NNcC936")); | ||
431 | + System.out.println(SkuUtil.getSkuEncWithOutVersion("9NNcC936")); | ||
432 | + | ||
433 | +// System.out.println(SkuUtil.decode("6HGkoES51V")); | ||
434 | + | ||
435 | + } | ||
436 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/SortList.java
0 → 100755
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 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/html/EscapeHtmlReference.java
0 → 100755
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 | + * TODO 这个应该用的,但没用到 | ||
8 | + */ | ||
9 | +public class EscapeHtmlReference extends EscapeReference { | ||
10 | + | ||
11 | + protected String escape(Object text) { | ||
12 | + if (!(text instanceof String)) { | ||
13 | + return text.toString(); | ||
14 | + } | ||
15 | + StringBuffer str = new StringBuffer(); | ||
16 | + char[] cs = text.toString().toCharArray(); | ||
17 | + for (char c : cs) { | ||
18 | + if (c == '>') { | ||
19 | + str.append(">"); | ||
20 | + } else if (c == '<') { | ||
21 | + str.append("<"); | ||
22 | + } else { | ||
23 | + str.append(c); | ||
24 | + } | ||
25 | + } | ||
26 | + return str.toString(); | ||
27 | + } | ||
28 | + | ||
29 | + protected String getMatchAttribute() { | ||
30 | + return "eventhandler.escape.html.match"; | ||
31 | + } | ||
32 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/web/BaseController.java
0 → 100755
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-api/src/main/java/com/dili/titan/common/utils/web/DateFormatUtils.java
0 → 100755
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 23:15:06 | ||
11 | + */ | ||
12 | + public String FORMAT_LONG = "yyyy-MM-dd HH:mm:ss"; | ||
13 | + /** | ||
14 | + * 精确到毫秒的完整时间 如:yyyy-MM-dd HH:mm:ss.S | ||
15 | + */ | ||
16 | + public String FORMAT_FULL = "yyyy-MM-dd HH:mm:ss.S"; | ||
17 | + /** | ||
18 | + * 获得默认的 date pattern | ||
19 | + */ | ||
20 | + public String getDatePattern() { | ||
21 | + return FORMAT_LONG; | ||
22 | + } | ||
23 | + /** | ||
24 | + * 根据预设格式返回当前日期 | ||
25 | + * @return | ||
26 | + */ | ||
27 | + public String getNow() { | ||
28 | + return format(new Date()); | ||
29 | + } | ||
30 | + /** | ||
31 | + * 根据用户格式返回当前日期 | ||
32 | + * @param format | ||
33 | + * @return | ||
34 | + */ | ||
35 | + public String getNow(String format) { | ||
36 | + return format(new Date(), format); | ||
37 | + } | ||
38 | + /** | ||
39 | + * 使用预设格式格式化日期 | ||
40 | + * @param date | ||
41 | + * @return | ||
42 | + */ | ||
43 | + public String format(Date date) { | ||
44 | + return format(date, getDatePattern()); | ||
45 | + } | ||
46 | + /** | ||
47 | + * 使用用户格式格式化日期 | ||
48 | + * @param date 日期 | ||
49 | + * @param pattern 日期格式 | ||
50 | + * @return | ||
51 | + */ | ||
52 | + public String format(Date date, String pattern) { | ||
53 | + String returnValue = ""; | ||
54 | + if (date != null) { | ||
55 | + SimpleDateFormat df = new SimpleDateFormat(pattern); | ||
56 | + returnValue = df.format(date); | ||
57 | + } | ||
58 | + return (returnValue); | ||
59 | + } | ||
60 | + /** | ||
61 | + * 使用预设格式提取字符串日期 | ||
62 | + * @param strDate 日期字符串 | ||
63 | + * @return | ||
64 | + */ | ||
65 | + public Date parse(String strDate) { | ||
66 | + return parse(strDate, getDatePattern()); | ||
67 | + } | ||
68 | + /** | ||
69 | + * 使用用户格式提取字符串日期 | ||
70 | + * @param strDate 日期字符串 | ||
71 | + * @param pattern 日期格式 | ||
72 | + * @return | ||
73 | + */ | ||
74 | + public Date parse(String strDate, String pattern) { | ||
75 | + SimpleDateFormat df = new SimpleDateFormat(pattern); | ||
76 | + try { | ||
77 | + return df.parse(strDate); | ||
78 | + } catch (ParseException e) { | ||
79 | + e.printStackTrace(); | ||
80 | + return null; | ||
81 | + } | ||
82 | + } | ||
83 | + /** | ||
84 | + * 在日期上增加数个整月 | ||
85 | + * @param date 日期 | ||
86 | + * @param n 要增加的月数 | ||
87 | + * @return | ||
88 | + */ | ||
89 | + public Date addMonth(Date date, int n) { | ||
90 | + Calendar cal = Calendar.getInstance(); | ||
91 | + cal.setTime(date); | ||
92 | + cal.add(Calendar.MONTH, n); | ||
93 | + return cal.getTime(); | ||
94 | + } | ||
95 | + /** | ||
96 | + * 在日期上增加天数 | ||
97 | + * @param date 日期 | ||
98 | + * @param n 要增加的天数 | ||
99 | + * @return | ||
100 | + */ | ||
101 | + public Date addDay(Date date, int n) { | ||
102 | + Calendar cal = Calendar.getInstance(); | ||
103 | + cal.setTime(date); | ||
104 | + cal.add(Calendar.DATE, n); | ||
105 | + return cal.getTime(); | ||
106 | + } | ||
107 | + /** | ||
108 | + * 获取时间戳 | ||
109 | + */ | ||
110 | + public String getTimeString() { | ||
111 | + SimpleDateFormat df = new SimpleDateFormat(FORMAT_FULL); | ||
112 | + Calendar calendar = Calendar.getInstance(); | ||
113 | + return df.format(calendar.getTime()); | ||
114 | + } | ||
115 | + /** | ||
116 | + * 获取日期年份 | ||
117 | + * @param date 日期 | ||
118 | + * @return | ||
119 | + */ | ||
120 | + public String getYear(Date date) { | ||
121 | + return format(date).substring(0, 4); | ||
122 | + } | ||
123 | + /** | ||
124 | + * 按默认格式的字符串距离今天的天数 | ||
125 | + * @param date 日期字符串 | ||
126 | + * @return | ||
127 | + */ | ||
128 | + public int countDays (String date) { | ||
129 | + long t = Calendar.getInstance().getTime().getTime(); | ||
130 | + Calendar c = Calendar.getInstance(); | ||
131 | + c.setTime(parse(date)); | ||
132 | + long t1 = c.getTime().getTime(); | ||
133 | + return (int)(t/1000 - t1/1000)/3600/24; | ||
134 | + } | ||
135 | + /** | ||
136 | + * 按用户格式字符串距离今天的天数 | ||
137 | + * @param date 日期字符串 | ||
138 | + * @param format 日期格式 | ||
139 | + * @return | ||
140 | + */ | ||
141 | + public int countDays (String date, String format) { | ||
142 | + long t = Calendar.getInstance().getTime().getTime(); | ||
143 | + Calendar c = Calendar.getInstance(); | ||
144 | + c.setTime(parse(date, format)); | ||
145 | + long t1 = c.getTime().getTime(); | ||
146 | + return (int)(t/1000 - t1/1000)/3600/24; | ||
147 | + } | ||
148 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/web/VelocitySupport.java
0 → 100755
1 | +package com.dili.titan.common.utils.web; | ||
2 | + | ||
3 | +import com.dili.titan.common.utils.web.exception.WebException; | ||
4 | +import org.apache.velocity.Template; | ||
5 | +import org.apache.velocity.VelocityContext; | ||
6 | +import org.apache.velocity.app.VelocityEngine; | ||
7 | +import org.slf4j.Logger; | ||
8 | +import org.slf4j.LoggerFactory; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.web.servlet.ModelAndView; | ||
11 | +import org.springframework.web.servlet.view.velocity.VelocityConfigurer; | ||
12 | + | ||
13 | +import javax.annotation.Resource; | ||
14 | +import java.io.StringWriter; | ||
15 | +import java.util.HashMap; | ||
16 | +import java.util.Map; | ||
17 | + | ||
18 | +public abstract class VelocitySupport { | ||
19 | + private final static Logger LOGGER = LoggerFactory | ||
20 | + .getLogger(VelocitySupport.class); | ||
21 | + | ||
22 | + // Velocity参数 | ||
23 | + protected final static String VELOCITY_DETAULT_LAYOUT = "layout/default"; | ||
24 | + protected final static String VELOCITY_ERROR_VIEW = "common/error"; | ||
25 | + protected final static String VELOCITY_VM_SUFFIX = ".vm"; | ||
26 | + protected final static String VELOCITY_SCREEN_CONTENT = "screen_content"; | ||
27 | + protected final static String VELOCITY_DEFAULT_MODEL_KEY = "model"; | ||
28 | + | ||
29 | + @Autowired | ||
30 | + private VelocityConfigurer velocityConfigurer; | ||
31 | + | ||
32 | + @Resource(name = "velocityTools") | ||
33 | + private Map<String, Object> velocityTools; | ||
34 | + | ||
35 | + /** | ||
36 | + * 输出VM模板,跳过布局 | ||
37 | + * | ||
38 | + * @param view | ||
39 | + * 视图 | ||
40 | + * 数据 | ||
41 | + * @return | ||
42 | + */ | ||
43 | + protected ModelAndView toVMSkipLayout(String view) { | ||
44 | + return toVMSkipLayout(view, null); | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * 输出VM模板,跳过布局 | ||
49 | + * | ||
50 | + * @param view | ||
51 | + * 视图 | ||
52 | + * @param model | ||
53 | + * 数据 | ||
54 | + * @return | ||
55 | + */ | ||
56 | + protected ModelAndView toVMSkipLayout(String view, Object model) { | ||
57 | + return toVM(null, view, model); | ||
58 | + } | ||
59 | + | ||
60 | + /** | ||
61 | + * 输出VM模板,默认布局 | ||
62 | + * | ||
63 | + * @param view | ||
64 | + * 视图 | ||
65 | + * @return | ||
66 | + */ | ||
67 | + protected ModelAndView toVM(String view) { | ||
68 | + return toVM(view, null); | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * 输出VM模板,默认布局 | ||
73 | + * | ||
74 | + * @param view | ||
75 | + * 视图 | ||
76 | + * @param model | ||
77 | + * 数据 | ||
78 | + * @return | ||
79 | + */ | ||
80 | + protected ModelAndView toVM(String view, Object model) { | ||
81 | + return toVM(VELOCITY_DETAULT_LAYOUT, view, model); | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * 输出VM模板,自定义布局 | ||
86 | + * | ||
87 | + * @param layout | ||
88 | + * 布局 | ||
89 | + * @param view | ||
90 | + * 视图 | ||
91 | + * @param model | ||
92 | + * 数据 | ||
93 | + * @return | ||
94 | + */ | ||
95 | + @SuppressWarnings("unchecked") | ||
96 | + protected ModelAndView toVM(String layout, String view, Object model) { | ||
97 | + VelocityEngine engine = velocityConfigurer.getVelocityEngine(); | ||
98 | + | ||
99 | + // 判断模板是否存在 | ||
100 | + String viewVM = view + VELOCITY_VM_SUFFIX; | ||
101 | + boolean exists = engine.resourceExists(viewVM); | ||
102 | + if (!exists) { | ||
103 | + throw new WebException("未找到指定视图[" + view + "]."); | ||
104 | + } | ||
105 | + | ||
106 | + Map<String, Object> context = getDefaultContext(); | ||
107 | + if (context == null) { | ||
108 | + context = new HashMap<String, Object>(); | ||
109 | + } | ||
110 | + | ||
111 | + // 添加默认数据 | ||
112 | + if (model instanceof Map) { | ||
113 | + context.putAll((Map<String, Object>) model); | ||
114 | + } else { | ||
115 | + context.put(VELOCITY_DEFAULT_MODEL_KEY, model); | ||
116 | + } | ||
117 | + | ||
118 | + if (LOGGER.isDebugEnabled()) { | ||
119 | + LOGGER.debug("process vm==============" + viewVM); | ||
120 | + } | ||
121 | + | ||
122 | + // 设置velocityUtils变量 | ||
123 | + if (velocityTools != null && !velocityTools.isEmpty()) { | ||
124 | + context.putAll(velocityTools); | ||
125 | + } | ||
126 | + | ||
127 | + if (layout == null) {// 跳过模板直接输出 | ||
128 | + return new ModelAndView(view, context); | ||
129 | + } | ||
130 | + | ||
131 | + // 判断布局模板是否存在 | ||
132 | + exists = engine.resourceExists(layout + VELOCITY_VM_SUFFIX); | ||
133 | + if (!exists) { | ||
134 | + throw new WebException("未找到指定布局模板[" + layout + "]."); | ||
135 | + } | ||
136 | + | ||
137 | + // 输入输出编码 | ||
138 | + Template bodyVM = engine.getTemplate(viewVM, | ||
139 | + (String) engine.getProperty(VelocityEngine.INPUT_ENCODING)); | ||
140 | + // 合并screen_content | ||
141 | + StringWriter screenContent = new StringWriter(); | ||
142 | + bodyVM.merge(new VelocityContext(context), screenContent); | ||
143 | + | ||
144 | + // 添加到默认布局中 | ||
145 | + context.put(VELOCITY_SCREEN_CONTENT, screenContent.toString()); | ||
146 | + | ||
147 | + return new ModelAndView(layout, context); | ||
148 | + } | ||
149 | + | ||
150 | + /** | ||
151 | + * velocity默认数据 | ||
152 | + * | ||
153 | + * @return | ||
154 | + */ | ||
155 | + protected abstract Map<String, Object> getDefaultContext(); | ||
156 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/web/VerifycodeUtils.java
0 → 100755
1 | +package com.dili.titan.common.utils.web; | ||
2 | + | ||
3 | +import javax.imageio.ImageIO; | ||
4 | +import javax.imageio.stream.ImageOutputStream; | ||
5 | +import java.awt.*; | ||
6 | +import java.awt.geom.AffineTransform; | ||
7 | +import java.awt.image.BufferedImage; | ||
8 | +import java.io.ByteArrayInputStream; | ||
9 | +import java.io.ByteArrayOutputStream; | ||
10 | +import java.io.InputStream; | ||
11 | +import java.util.Random; | ||
12 | + | ||
13 | +/** | ||
14 | + * 生成验证码工具类 | ||
15 | + */ | ||
16 | +public class VerifycodeUtils { | ||
17 | + | ||
18 | + public static final int DEFAULT_LENGTH = 4; | ||
19 | + public static final int WIDTH = 85; | ||
20 | + public static final int HEIGHT = 26; | ||
21 | + public static final String VERIFY_CODE_KEY = "_dl_vd"; | ||
22 | + | ||
23 | + private static final String[] fontTypes = {"\u5b8b\u4f53","\u65b0\u5b8b\u4f53","\u9ed1\u4f53","\u6977\u4f53", | ||
24 | + "\u96b6\u4e66"}; | ||
25 | + | ||
26 | + private static final char[] codeSequence = { 'A','a', 'B','b', 'C','c', 'D','d', 'E', 'e','F','f', 'G', 'g', 'H','h', | ||
27 | + 'J','j', 'K', 'k', 'M','m', 'N','n', 'P','p', 'Q','q', 'R','r', 'S','s', 'T','t', | ||
28 | + 'U','u', 'V', 'v','W', 'w','X', 'x','Y', 'y','Z', 'z','2', '3', '4', '5', | ||
29 | + '6', '7', '8', '9' }; | ||
30 | + | ||
31 | + /** | ||
32 | + * 返回一个长度为length的随机字符串 | ||
33 | + * | ||
34 | + * @param length | ||
35 | + * @return | ||
36 | + */ | ||
37 | + private static String getRandomSting(int length) { | ||
38 | + Random random = new Random(); | ||
39 | + StringBuilder randomCode = new StringBuilder(); | ||
40 | + for (int i = 0; i < length; i++) { | ||
41 | + String strRand = String.valueOf(codeSequence[random.nextInt(codeSequence.length)]); | ||
42 | + randomCode.append(strRand); | ||
43 | + } | ||
44 | + return randomCode.toString(); | ||
45 | + } | ||
46 | + | ||
47 | + public static BufferedImage getNextCodeImage(int length) { | ||
48 | + String verifyCode = getRandomSting(length); | ||
49 | + if (length < 1) throw new RuntimeException("length can not be less than 1."); | ||
50 | + return createImage(verifyCode); | ||
51 | + } | ||
52 | + | ||
53 | + public static BufferedImage createCodeImage(String code) { | ||
54 | + return createImage(code); | ||
55 | + } | ||
56 | + | ||
57 | + public static BufferedImage createImage(String code) { | ||
58 | + int x_v = WIDTH / (code.length() + 1); | ||
59 | + int codeY = HEIGHT - 4; | ||
60 | + BufferedImage buffImg = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); | ||
61 | + Graphics2D g = buffImg.createGraphics(); | ||
62 | + Random random = new Random(); | ||
63 | + g.setColor(Color.WHITE); | ||
64 | + g.fillRect(0, 0, WIDTH, HEIGHT); | ||
65 | + Font font = new Font("Arial", Font.BOLD, 5); | ||
66 | + g.setFont(font); | ||
67 | + g.setColor(Color.WHITE); | ||
68 | + g.drawRect(0, 0, WIDTH - 1, HEIGHT - 1); | ||
69 | + g.setColor(Color.YELLOW); | ||
70 | + for (int i = 0; i < 2; i++) { | ||
71 | + g.setColor(new Color(random.nextInt(255), random.nextInt(255), random | ||
72 | + .nextInt(255)).darker()); | ||
73 | + g.drawLine(i, HEIGHT / 2 + random.nextInt(3), WIDTH, HEIGHT / 2 + random.nextInt(8)); | ||
74 | + } | ||
75 | + StringBuffer randomCode = new StringBuffer(); | ||
76 | + int red = 0, green = 0, blue = 0; | ||
77 | + AffineTransform fontAT = new AffineTransform(); | ||
78 | + for (int i = 0; i < code.length(); i++) { | ||
79 | + String strRand = new String(new char[] { code.charAt(i) }); | ||
80 | + red = random.nextInt(255); | ||
81 | + green = random.nextInt(255); | ||
82 | + blue = random.nextInt(255); | ||
83 | + g.setFont(new Font(fontTypes[random.nextInt(fontTypes.length)], Font.BOLD, 20 + random.nextInt(6))); | ||
84 | + // 产生弧度 | ||
85 | + int rotate = random.nextInt(7); | ||
86 | + fontAT.rotate(random.nextBoolean() ? Math.toRadians((double)rotate) : - Math.toRadians((double)rotate / 2)); | ||
87 | + | ||
88 | + Font fx = new Font(new String[] { "Times New Roman", "Verdana", "Arial" }[random.nextInt(2)], 1, 24).deriveFont(fontAT); | ||
89 | + | ||
90 | + | ||
91 | + g.setFont(fx); | ||
92 | + g.setColor(new Color(red, green, blue).darker()); | ||
93 | + g.drawString(strRand, (i) * x_v, codeY); | ||
94 | + randomCode.append(strRand); | ||
95 | + } | ||
96 | + g.dispose(); | ||
97 | + return buffImg; | ||
98 | + } | ||
99 | + | ||
100 | + | ||
101 | + public static BufferedImage getNextCodeImage() { | ||
102 | + return getNextCodeImage(VerifycodeUtils.DEFAULT_LENGTH); | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * 获取图片信息的输入流 | ||
107 | + * | ||
108 | + * @param bufferImg | ||
109 | + * @return | ||
110 | + * @throws Exception | ||
111 | + */ | ||
112 | + public static InputStream getInputStream(BufferedImage bufferImg) throws Exception { | ||
113 | + ByteArrayOutputStream output = new ByteArrayOutputStream(); | ||
114 | + ImageOutputStream imageOut = ImageIO.createImageOutputStream(output); | ||
115 | + ImageIO.write(bufferImg, "JPEG", imageOut); | ||
116 | + ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); | ||
117 | + imageOut.close(); | ||
118 | + output.close(); | ||
119 | + return input; | ||
120 | + } | ||
121 | + | ||
122 | + | ||
123 | + //public static void main(String[] args) throws FileNotFoundException, IOException { | ||
124 | + // String code = VerifycodeUtils.getRandomSting(5); | ||
125 | + // BufferedImage bufferImg = VerifycodeUtils.createCodeImage(code); | ||
126 | + // ImageIO.write(bufferImg, "JPEG", new FileOutputStream("D:/verify1.jpg")); | ||
127 | + // System.out.println(code); | ||
128 | + //} | ||
129 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/web/ViewBuilder.java
0 → 100755
1 | +package com.dili.titan.common.utils.web; | ||
2 | + | ||
3 | +import org.springframework.web.servlet.ModelAndView; | ||
4 | + | ||
5 | +import java.util.HashMap; | ||
6 | +import java.util.Map; | ||
7 | + | ||
8 | +public class ViewBuilder { | ||
9 | + | ||
10 | + private BaseController baseController; | ||
11 | + private String template; | ||
12 | + private Map<String, Object> params = new HashMap<String, Object>(); | ||
13 | + | ||
14 | + public ViewBuilder(String template, BaseController bc) { | ||
15 | + this.template = template; | ||
16 | + this.baseController = bc; | ||
17 | + } | ||
18 | + | ||
19 | + public ModelAndView build() { | ||
20 | + return baseController.toVM(template, params); | ||
21 | + } | ||
22 | + | ||
23 | + public ViewBuilder param(String key, Object value) { | ||
24 | + params.put(key, value); | ||
25 | + return this; | ||
26 | + } | ||
27 | + | ||
28 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/web/exception/ErrorController.java
0 → 100755
1 | +package com.dili.titan.common.utils.web.exception; | ||
2 | + | ||
3 | +import com.dili.titan.common.utils.web.BaseController; | ||
4 | +import org.springframework.stereotype.Controller; | ||
5 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
6 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
7 | +import org.springframework.web.servlet.ModelAndView; | ||
8 | + | ||
9 | +import javax.servlet.http.HttpServletRequest; | ||
10 | +import java.util.HashMap; | ||
11 | +import java.util.Map; | ||
12 | + | ||
13 | +@Controller | ||
14 | +//TODO 这个应该用的,但没用到 | ||
15 | +public class ErrorController extends BaseController { | ||
16 | + | ||
17 | + @RequestMapping("/error500") | ||
18 | + @ResponseBody | ||
19 | + public ModelAndView error500(HttpServletRequest request){ | ||
20 | + | ||
21 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
22 | + map.put("status", request.getAttribute("javax.servlet.error.status_code")); | ||
23 | + map.put("reason", request.getAttribute("javax.servlet.error.message")); | ||
24 | + map.put("exception", request.getAttribute("javax.servlet.error.exception")); | ||
25 | + map.put("exception_type", request.getAttribute("javax.servlet.error.exception_type")); | ||
26 | + map.put("request_uri", request.getAttribute("javax.servlet.error.request_uri")); | ||
27 | + map.put("servlet_name", request.getAttribute("javax.servlet.error.servlet_name")); | ||
28 | + | ||
29 | + return toVM("common/error500",map); | ||
30 | + } | ||
31 | + | ||
32 | + @RequestMapping("/error404") | ||
33 | + @ResponseBody | ||
34 | + public ModelAndView error404(HttpServletRequest request){ | ||
35 | + | ||
36 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
37 | + map.put("status", request.getAttribute("javax.servlet.error.status_code")); | ||
38 | + map.put("reason", request.getAttribute("javax.servlet.error.message")); | ||
39 | + map.put("exception", request.getAttribute("javax.servlet.error.exception")); | ||
40 | + map.put("exception_type", request.getAttribute("javax.servlet.error.exception_type")); | ||
41 | + map.put("request_uri", request.getAttribute("javax.servlet.error.request_uri")); | ||
42 | + map.put("servlet_name", request.getAttribute("javax.servlet.error.servlet_name")); | ||
43 | + | ||
44 | + return toVM("common/error404",map); | ||
45 | + } | ||
46 | + | ||
47 | +} |
titan-api/src/main/java/com/dili/titan/common/utils/web/exception/WebException.java
0 → 100755
1 | +package com.dili.titan.common.utils.web.exception; | ||
2 | + | ||
3 | +public class WebException extends RuntimeException{ | ||
4 | + private static final long serialVersionUID = -4573550295666184287L; | ||
5 | + | ||
6 | + public WebException(String msg){ | ||
7 | + super(msg); | ||
8 | + } | ||
9 | + | ||
10 | + public WebException(Throwable cause){ | ||
11 | + super(cause); | ||
12 | + } | ||
13 | + | ||
14 | + public WebException(String msg, Throwable cause){ | ||
15 | + super(msg, cause); | ||
16 | + } | ||
17 | +} |
titan-api/src/main/java/com/dili/titan/dao/AttributeDao.java
0 → 100755
1 | +/* | ||
2 | + * Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
3 | + * 本软件源代码版权归----所有,未经许可不得任意复制与传播. | ||
4 | + */ | ||
5 | +package com.dili.titan.dao; | ||
6 | + | ||
7 | +import com.dili.titan.dao.base.BaseDao; | ||
8 | +import com.dili.titan.domain.Attribute; | ||
9 | + | ||
10 | +/** | ||
11 | + * AttributeDao 接口 | ||
12 | + * | ||
13 | + * @author dev-center | ||
14 | + * @since 2014-05-10 | ||
15 | + */ | ||
16 | +public interface AttributeDao extends BaseDao<Attribute, Long> { | ||
17 | + | ||
18 | +} |
titan-api/src/main/java/com/dili/titan/dao/AttributeValueDao.java
0 → 100755
1 | +/* | ||
2 | + * Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
3 | + * 本软件源代码版权归----所有,未经许可不得任意复制与传播. | ||
4 | + */ | ||
5 | +package com.dili.titan.dao; | ||
6 | + | ||
7 | +import com.dili.titan.dao.base.BaseDao; | ||
8 | +import com.dili.titan.domain.AttributeValue; | ||
9 | + | ||
10 | +import java.util.List; | ||
11 | + | ||
12 | +/** | ||
13 | + * AttributeDao 接口 | ||
14 | + * | ||
15 | + * @author dev-center | ||
16 | + * @since 2014-05-10 | ||
17 | + */ | ||
18 | +public interface AttributeValueDao extends BaseDao<AttributeValue, Long> { | ||
19 | + /** | ||
20 | + * 查询属性的所有属性值 | ||
21 | + * | ||
22 | + * @param attrId | ||
23 | + * @return | ||
24 | + */ | ||
25 | + public List<AttributeValue> getAttributeValues(long attrId); | ||
26 | + | ||
27 | +} |
titan-api/src/main/java/com/dili/titan/dao/AuthDao.java
0 → 100755
1 | +/* | ||
2 | + * Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
3 | + * 本软件源代码版权归----所有,未经许可不得任意复制与传播. | ||
4 | + */ | ||
5 | +package com.dili.titan.dao; | ||
6 | + | ||
7 | +import com.dili.titan.dao.base.BaseDao; | ||
8 | +import com.dili.titan.domain.Auth; | ||
9 | + | ||
10 | +import java.util.List; | ||
11 | + | ||
12 | +/** | ||
13 | + * AuthDao 接口 | ||
14 | + * @author dev-center | ||
15 | + * @since 2014-10-29 | ||
16 | + */ | ||
17 | +public interface AuthDao extends BaseDao<Auth,Long>{ | ||
18 | + | ||
19 | + /** | ||
20 | + * 根据运营范围查询当前正在生效的认证 | ||
21 | + * @param scope 运营范围 | ||
22 | + * @return | ||
23 | + */ | ||
24 | + public List<Auth> findNormalAuthByScope(Integer scope); | ||
25 | +} |
titan-api/src/main/java/com/dili/titan/dao/AuthScopeDao.java
0 → 100755
1 | +/* | ||
2 | + * Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
3 | + * 本软件源代码版权归----所有,未经许可不得任意复制与传播. | ||
4 | + */ | ||
5 | +package com.dili.titan.dao; | ||
6 | + | ||
7 | +import com.dili.titan.dao.base.BaseDao; | ||
8 | +import com.dili.titan.domain.AuthScope; | ||
9 | + | ||
10 | +/** | ||
11 | + * AuthScopeDao 接口 | ||
12 | + * @author dev-center | ||
13 | + * @since 2014-10-29 | ||
14 | + */ | ||
15 | +public interface AuthScopeDao extends BaseDao<AuthScope,Long>{ | ||
16 | + //自定义扩展 | ||
17 | + | ||
18 | +} |
titan-api/src/main/java/com/dili/titan/dao/CategorySearchAttrDao.java
0 → 100755
1 | +/* | ||
2 | + * Copyright (c) 2015 www.diligrp.com All rights reserved. | ||
3 | + * 本软件源代码版权归----所有,未经许可不得任意复制与传播. | ||
4 | + */ | ||
5 | +package com.dili.titan.dao; | ||
6 | + | ||
7 | +import com.dili.titan.dao.base.BaseDao; | ||
8 | +import com.dili.titan.domain.CategorySearchAttr; | ||
9 | + | ||
10 | +/** | ||
11 | + * CategorySearchAttrDao 接口 | ||
12 | + * @author dev-center | ||
13 | + * @since 2015-04-14 | ||
14 | + */ | ||
15 | +public interface CategorySearchAttrDao extends BaseDao<CategorySearchAttr,Long> { | ||
16 | + //自定义扩展 | ||
17 | + | ||
18 | +} | ||
0 | \ No newline at end of file | 19 | \ No newline at end of file |
titan-api/src/main/java/com/dili/titan/dao/IndexCategoryDao.java
0 → 100755
1 | +/* | ||
2 | + * Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
3 | + * 本软件源代码版权归----所有,未经许可不得任意复制与传播. | ||
4 | + */ | ||
5 | +package com.dili.titan.dao; | ||
6 | +import com.dili.titan.dao.base.BaseDao; | ||
7 | +import com.dili.titan.domain.IndexCategory; | ||
8 | + | ||
9 | +/** | ||
10 | + * IndexCategoryDao 接口 | ||
11 | + * @author dev-center | ||
12 | + * @since 2014-12-22 | ||
13 | + */ | ||
14 | + | ||
15 | +public interface IndexCategoryDao extends BaseDao<IndexCategory,Long>{ | ||
16 | + //自定义扩展 | ||
17 | + | ||
18 | +} |
titan-api/src/main/java/com/dili/titan/dao/VideoDao.java
0 → 100755
1 | +/* | ||
2 | + * Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
3 | + * 本软件源代码版权归----所有,未经许可不得任意复制与传播. | ||
4 | + */ | ||
5 | +package com.dili.titan.dao; | ||
6 | + | ||
7 | +import com.dili.titan.dao.base.BaseDao; | ||
8 | +import com.dili.titan.domain.Video; | ||
9 | + | ||
10 | +/** | ||
11 | + * VideoDao 接口 | ||
12 | + * @author dev-center | ||
13 | + * @since 2014-12-26 | ||
14 | + */ | ||
15 | +public interface VideoDao extends BaseDao<Video,Long>{ | ||
16 | + //自定义扩展 | ||
17 | + | ||
18 | + /** | ||
19 | + * 根据商品ID获取视频信息 | ||
20 | + * @param pid | ||
21 | + * @return | ||
22 | + */ | ||
23 | + public Video selectVideoByPid(Long pid); | ||
24 | +} |