Skip to content

Commit afbbd63

Browse files
committed
util kotlin
1 parent 2e9eea9 commit afbbd63

File tree

21 files changed

+189
-354
lines changed

21 files changed

+189
-354
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@
1414
- mysql5.5+
1515
- git: 版本管理
1616
- nginx: 反向代理服务器
17-
- lombok
1817

1918

2019
### 注意事项
2120
- 本项目代码托管在[github](https://github.com/xiaomoinfo/SpringBootUnity)[码云](http://git.oschina.net/hupeng/SpringBootUnity)两个地方,最新代码会先推送在github上,码云上会在github上更新完之后进行同步。
2221
- 本项目多数数据库都用到了`hibernate`,如果没有提供`sql`文件。则启动时会根据代码映射自动生成数据库表,请在启动前修改`application.properties`中的数据库连接信息
23-
- 本项目使用了`lombok`,在查看本项目时如果您没有下载`lombok 插件`,请先安装,不然找不到`get/set`方法。eclipse用户请参照[官网](http://jnb.ociweb.com/jnb/jnbJan2010.html#references)
24-
25-
![lombok](screenshot/lombok.png)
2622

2723

2824
### 启动方式

core/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@
6363
<groupId>commons-fileupload</groupId>
6464
<artifactId>commons-fileupload</artifactId>
6565
</dependency>
66-
<dependency>
67-
<groupId>org.projectlombok</groupId>
68-
<artifactId>lombok</artifactId>
69-
</dependency>
7066
<dependency>
7167
<groupId>dom4j</groupId>
7268
<artifactId>dom4j</artifactId>

core/src/main/java/info/xiaomo/core/untils/DownUtil.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package info.xiaomo.core.untils;
22

3-
import lombok.extern.slf4j.Slf4j;
4-
53
import java.io.File;
64
import java.io.FileOutputStream;
75
import java.io.InputStream;
@@ -11,10 +9,8 @@
119

1210
/**
1311
* @author : xiaomo (https://xiaomo.info) (https://github.com/xiaomoinfo)
14-
*
1512
* @created : 2016/12/26 13:25
1613
*/
17-
@Slf4j
1814
public class DownUtil {
1915

2016
public static void download(String urlString) throws Exception {
@@ -64,10 +60,10 @@ public static void download(String urlString, String filePath) throws Exception
6460
// 输出的文件流
6561

6662
File output = new File(filePath);
67-
if (!output.exists()){
63+
if (!output.exists()) {
6864
boolean res = output.mkdir();
69-
if (res){
70-
log.debug("{} 目录创建成功", filePath);
65+
if (res) {
66+
System.out.println("目录创建成功" + filePath);
7167
}
7268
}
7369

core/src/main/java/info/xiaomo/core/untils/Md5Util.java

Lines changed: 0 additions & 88 deletions
This file was deleted.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package info.xiaomo.core.untils
2+
3+
import java.security.MessageDigest
4+
5+
/**
6+
* │\__╭╭╭╭╭__/│
7+
* │         │
8+
* │         │
9+
* │ -      -│
10+
* │≡    o ≡ │
11+
* │         │
12+
* ╰——┬O◤▽◥O┬——╯
13+
* |  o  |
14+
* |╭---╮把今天最好的表现当作明天最新的起点..~
15+
* いま 最高の表現 として 明日最新の始発..~
16+
* Today the best performance as tomorrow newest starter!
17+
* Created by IntelliJ IDEA.
18+
*
19+
* @author : xiaomo
20+
* github: https://github.com/xiaomoinfo
21+
22+
*
23+
*
24+
* Date: 16/4/3 10:03
25+
* Description: md5加密解密
26+
* Copyright(©) 2015 by xiaomo.
27+
*/
28+
object Md5Util {
29+
30+
private val HEX_DIGITS = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f")
31+
32+
/**
33+
* 转换字节数组为16进制字串
34+
*
35+
* @param b 字节数组
36+
* @return 16进制字串
37+
*/
38+
fun byteArrayToString(b: ByteArray): String {
39+
val resultSb = StringBuilder()
40+
for (aB in b) {
41+
//若使用本函数转换则可得到加密结果的16进制表示,即数字字母混合的形式
42+
resultSb.append(byteToHexString(aB))
43+
}
44+
return resultSb.toString()
45+
}
46+
47+
private fun byteToNumString(b: Byte): String {
48+
49+
var tempB = b.toInt()
50+
if (tempB < 0) {
51+
tempB += 256
52+
}
53+
54+
return tempB.toString()
55+
}
56+
57+
private fun byteToHexString(b: Byte): String {
58+
var n = b.toInt()
59+
if (n < 0) {
60+
n = 256 + n
61+
}
62+
val d1 = n / 16
63+
val d2 = n % 16
64+
return HEX_DIGITS[d1] + HEX_DIGITS[d2]
65+
}
66+
67+
fun encode(password: String, salt: String): String? {
68+
var resultString: String? = null
69+
try {
70+
resultString = password + salt
71+
val md = MessageDigest.getInstance("md5")
72+
resultString = byteArrayToString(md.digest(resultString.toByteArray()))
73+
} catch (ex: Exception) {
74+
ex.printStackTrace()
75+
}
76+
77+
return resultString
78+
}
79+
80+
@JvmStatic
81+
fun main(args: Array<String>) {
82+
val password = "xiaomo"
83+
val salt = RandomUtil.createSalt()
84+
println("原数据:" + password)
85+
println("盐值:" + salt)
86+
println("MD5后:" + encode(password, salt))
87+
}
88+
89+
}

crawler/src/main/java/info/xiaomo/crawler/model/ShikigamiModel.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package info.xiaomo.crawler.model
22

33
import info.xiaomo.core.base.BaseModel
4-
import lombok.EqualsAndHashCode
54
import javax.persistence.Entity
65
import javax.persistence.Table
76

@@ -12,7 +11,6 @@ import javax.persistence.Table
1211

1312
@Entity
1413
@Table(name = "shikigame")
15-
@EqualsAndHashCode(callSuper = false)
1614
class ShikigamiModel : BaseModel() {
1715

1816
/**

freemarker/src/main/java/info/xiaomo/freemarker/FreemarkerMain.java

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package info.xiaomo.freemarker
2+
3+
import org.springframework.boot.SpringApplication
4+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
5+
import org.springframework.boot.autoconfigure.domain.EntityScan
6+
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
7+
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
8+
import org.springframework.context.annotation.ComponentScan
9+
10+
/**
11+
* 把今天最好的表现当作明天最新的起点..~
12+
* いま 最高の表現 として 明日最新の始発..~
13+
* Today the best performance as tomorrow newest starter!
14+
* Created by IntelliJ IDEA.
15+
*
16+
* @author : xiaomo
17+
* github: https://github.com/xiaomoinfo
18+
19+
*
20+
* Date: 2016/4/1 15:38
21+
* Copyright(©) 2015 by xiaomo.
22+
*/
23+
@ComponentScan("info.xiaomo")
24+
@EntityScan("info.xiaomo.*.model")
25+
@EnableAutoConfiguration(exclude = arrayOf(DataSourceAutoConfiguration::class, HibernateJpaAutoConfiguration::class))
26+
class FreemarkerMain {
27+
28+
@Throws(Exception::class)
29+
fun main(args: Array<String>) {
30+
SpringApplication.run(FreemarkerMain::class.java, *args)
31+
}
32+
33+
34+
}

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,6 @@
163163
<artifactId>mail</artifactId>
164164
<version>${javax-mail.version}</version>
165165
</dependency>
166-
<dependency>
167-
<groupId>org.projectlombok</groupId>
168-
<artifactId>lombok</artifactId>
169-
<version>${lombak.version}</version>
170-
</dependency>
171166
<!-- Swagger -->
172167
<dependency>
173168
<groupId>io.springfox</groupId>

scheduled/src/main/java/info/xiaomo/scheduled/task/ScheduledTasks.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)