Skip to content

Commit d1ed707

Browse files
committed
java to kotlin
1 parent 2976789 commit d1ed707

File tree

48 files changed

+792
-846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+792
-846
lines changed

core/src/main/java/info/xiaomo/core/base/BaseModel.kt

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

3-
import lombok.Data
43
import java.io.Serializable
54
import java.util.*
65
import javax.persistence.*
@@ -20,7 +19,6 @@ import javax.persistence.*
2019
*/
2120

2221
@MappedSuperclass
23-
@Data
2422
abstract class BaseModel : Serializable {
2523

2624
@Id

core/src/main/java/info/xiaomo/core/base/Result.kt

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

3-
import lombok.Data
4-
53
/**
64
* 把今天最好的表现当作明天最新的起点..~
75
* いま 最高の表現 として 明日最新の始発..~
@@ -16,7 +14,7 @@ import lombok.Data
1614
* Description: 返回结果
1715
* Copyright(©) 2015 by xiaomo.
1816
*/
19-
@Data
17+
2018
class Result<T> {
2119

2220
private var resultCode = 200

crawler/src/main/java/info/xiaomo/crawler/dao/ShikigamaDao.java

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package info.xiaomo.crawler.dao
2+
3+
import info.xiaomo.crawler.model.ShikigamiModel
4+
import org.springframework.data.jpa.repository.JpaRepository
5+
import org.springframework.stereotype.Repository
6+
7+
/**
8+
* @author : xiaomo (https://xiaomo.info) (https://github.com/xiaomoinfo)
9+
* @created : 2016/12/24 15:55
10+
*/
11+
@Repository
12+
interface ShikigamaDao : JpaRepository<ShikigamiModel, Long> {
13+
14+
/**
15+
* 根据名字查式神
16+
*
17+
* @param name
18+
* @return
19+
*/
20+
fun findByName(name: String): ShikigamiModel
21+
}
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
package info.xiaomo.crawler.model;
1+
package info.xiaomo.crawler.model
22

33

4-
import info.xiaomo.core.base.BaseModel;
4+
import info.xiaomo.core.base.BaseModel
55

66
/**
77
* @author : xiaomo (https://xiaomo.info) (https://github.com/xiaomoinfo)
88
* @created : 2016/12/24 18:06
99
* 御魂模型
1010
*/
11-
public class MitamaModel extends BaseModel {
11+
class MitamaModel : BaseModel() {
1212

1313
/**
1414
* 名字
1515
* 火灵
1616
*/
17-
private String name;
17+
private val mitamaMame: String? = null
1818

1919
/**
2020
* icon
2121
* http://uus-ng.img.d.cn/snapshot/201610/999/image/388/388/hd/20161012151646257.jpeg
2222
*/
23-
private String image;
23+
private val image: String? = null
2424

2525
/**
2626
* 两件套效果
2727
* 效果命中+15%
2828
*/
29-
private String effect2;
29+
private val effect2: String? = null
3030

3131
/**
3232
* 四件套效果
3333
* 初次出场时获得额外3点鬼火(新回目战斗开始也会被计为初次出场)
3434
*/
35-
private String effect4;
35+
private val effect4: String? = null
3636

3737
/**
3838
* 关键字
3939
*/
40-
private String keyworld;
40+
private val keyworld: String? = null
4141

4242
/**
4343
* 推荐式神
4444
* 青行灯
4545
*/
46-
private String suggest;
46+
private val suggest: String? = null
4747

4848

4949
/**
5050
* 获取方式
5151
* 神秘商店、周末御魂
5252
*/
53-
private String getWay;
53+
private val getWay: String? = null
5454

5555

5656
}

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

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

33
import info.xiaomo.core.base.BaseModel
4-
import lombok.Data
54
import lombok.EqualsAndHashCode
6-
import lombok.ToString
75
import javax.persistence.Entity
86
import javax.persistence.Table
97

@@ -14,8 +12,6 @@ import javax.persistence.Table
1412

1513
@Entity
1614
@Table(name = "shikigame")
17-
@Data
18-
@ToString(callSuper = true)
1915
@EqualsAndHashCode(callSuper = false)
2016
class ShikigamiModel : BaseModel() {
2117

crawler/src/main/java/info/xiaomo/crawler/schedule/ScheduledTasks.java

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package info.xiaomo.crawler.schedule
2+
3+
import info.xiaomo.core.untils.DownUtil
4+
import info.xiaomo.crawler.service.ShikigamaService
5+
import info.xiaomo.crawler.spider.OnnmyoujiSpider
6+
import org.slf4j.LoggerFactory
7+
import org.springframework.beans.factory.annotation.Autowired
8+
import org.springframework.scheduling.annotation.Scheduled
9+
import org.springframework.stereotype.Component
10+
import java.text.SimpleDateFormat
11+
import java.util.*
12+
13+
/**
14+
* @author : xiaomo (https://xiaomo.info) (https://github.com/xiaomoinfo)
15+
* @created : 2016/12/24 15:59
16+
*/
17+
@Component
18+
class ScheduledTasks @Autowired
19+
constructor(private val shikigamaService: ShikigamaService) {
20+
21+
22+
@Scheduled(fixedRate = (1000 * 30).toLong())
23+
fun reportCurrentTime() {
24+
println("Scheduling Tasks Examples: The time is now " + dateFormat().format(Date()))
25+
}
26+
27+
//每1分钟执行一次
28+
@Scheduled(cron = "0 */1 * * * * ")
29+
fun reportCurrentByCron() {
30+
LOGGER.debug("开始执行任务:")
31+
val shikigamiModel = OnnmyoujiSpider.shikigamiModel
32+
for (model in shikigamiModel) {
33+
shikigamaService.save(model)
34+
}
35+
}
36+
37+
@Scheduled(fixedRate = 1000)
38+
@Throws(Exception::class)
39+
fun downImage() {
40+
LOGGER.debug("开始执行任务:")
41+
val shikigamiModel = shikigamaService.findAll()
42+
for (aShikigamiModel in shikigamiModel) {
43+
val url = aShikigamiModel.image
44+
DownUtil.download(url, "D:\\yys\\")
45+
LOGGER.debug("开始下载图片:{}", url)
46+
}
47+
}
48+
49+
50+
private fun dateFormat(): SimpleDateFormat {
51+
return SimpleDateFormat("HH:mm:ss")
52+
}
53+
54+
companion object {
55+
56+
private val LOGGER = LoggerFactory.getLogger(ScheduledTasks::class.java)
57+
}
58+
59+
}

mongodb/src/main/java/info/xiaomo/mongodb/MongodbMain.java

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

0 commit comments

Comments
 (0)