Skip to content

Commit 9d018c3

Browse files
committed
async java to kotlin
1 parent c6549b5 commit 9d018c3

Some content is hidden

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

59 files changed

+2276
-2425
lines changed

async/src/main/java/info/xiaomo/anysc/controller/TestController.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import org.springframework.web.bind.annotation.RestController
2525

2626
@RestController
2727
@RequestMapping("/")
28-
class TestController @Autowired
29-
constructor(private val task: AsyncTask) {
28+
class TestController
29+
@Autowired constructor(private val task: AsyncTask) {
3030

3131
@RequestMapping(value = "/", method = arrayOf(RequestMethod.GET))
3232
@Throws(Exception::class)
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
package info.xiaomo.core.base;
1+
package info.xiaomo.core.base
22

3-
import org.springframework.web.bind.annotation.PathVariable;
4-
5-
import java.util.Date;
3+
import org.springframework.web.bind.annotation.PathVariable
4+
import java.util.*
65

76
/**
87
* @author : xiaomo (https://xiaomo.info) (https://github.com/xiaomoinfo)
98
* @version : 2017/1/13 9:51
109
*/
11-
public interface AuthOperate {
10+
interface AuthOperate {
1211

1312

1413
/**
@@ -18,7 +17,7 @@ public interface AuthOperate {
1817
* @param password 密码
1918
* @return 结果
2019
*/
21-
Result<Boolean> login(@PathVariable String name, @PathVariable String password);
20+
fun login(@PathVariable name: String, @PathVariable password: String): Result<Boolean>
2221

2322

2423
/**
@@ -28,7 +27,7 @@ public interface AuthOperate {
2827
* @param password 密码
2928
* @return 结果
3029
*/
31-
Result<Boolean> changePassword(@PathVariable String name, @PathVariable String password);
30+
fun changePassword(@PathVariable name: String, @PathVariable password: String): Result<Boolean>
3231

3332
/**
3433
* 注册
@@ -37,7 +36,7 @@ public interface AuthOperate {
3736
* @param password 密码
3837
* @return 是否己发送验证码
3938
*/
40-
Result<Boolean> register(@PathVariable String name, @PathVariable String password);
39+
fun register(@PathVariable name: String, @PathVariable password: String): Result<Boolean>
4140

4241
/**
4342
* 验证
@@ -46,6 +45,6 @@ public interface AuthOperate {
4645
* @param time 发送时间
4746
* @return 是否验证通过
4847
*/
49-
Result<Boolean> validate(@PathVariable int validCode, @PathVariable Date time);
48+
fun validate(@PathVariable validCode: Int, @PathVariable time: Date): Result<Boolean>
5049

5150
}

core/src/main/java/info/xiaomo/core/base/BaseController.java

Lines changed: 0 additions & 96 deletions
This file was deleted.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package info.xiaomo.core.base
2+
3+
import org.slf4j.LoggerFactory
4+
import org.springframework.data.domain.Page
5+
import org.springframework.web.bind.annotation.PathVariable
6+
import org.springframework.web.bind.annotation.RequestBody
7+
import org.springframework.web.bind.annotation.RestController
8+
9+
/**
10+
* @author : xiaomo (https://xiaomo.info) (https://github.com/xiaomoinfo)
11+
* @version : 2017/1/11 16:41
12+
*/
13+
@RestController
14+
abstract class BaseController<T> {
15+
16+
protected val LOGGER = LoggerFactory.getLogger(javaClass)
17+
18+
/**
19+
* 查找所有(不带分页)
20+
*
21+
* @return result
22+
*/
23+
abstract fun findAll(): Result<List<T>>
24+
25+
/**
26+
* 带分页
27+
*
28+
* @param start 起始页
29+
* @param pageSize 页码数
30+
* @return result
31+
*/
32+
abstract fun findAll(@PathVariable start: Int, @PathVariable pageSize: Int): Result<Page<T>>
33+
34+
/**
35+
* 根据id查看模型
36+
*
37+
* @param id id
38+
* @return result
39+
*/
40+
abstract fun findById(@PathVariable id: Long?): Result<T>
41+
42+
/**
43+
* 根据名字查找模型
44+
*
45+
* @param name name
46+
* @return result
47+
*/
48+
abstract fun findByName(@PathVariable name: String): Result<T>
49+
50+
/**
51+
* 根据名字删除模型
52+
*
53+
* @param name name
54+
* @return result
55+
*/
56+
abstract fun delByName(@PathVariable name: String): Result<Boolean>
57+
58+
59+
/**
60+
* 根据id删除模型
61+
*
62+
* @param id id
63+
* @return result
64+
*/
65+
abstract fun delById(@PathVariable id: Long?): Result<Boolean>
66+
67+
/**
68+
* 添加模型
69+
*
70+
* @param model model
71+
* @return result
72+
*/
73+
abstract fun add(@RequestBody model: T): Result<Boolean>
74+
75+
76+
/**
77+
* 更新
78+
*
79+
* @param model model
80+
* @return result
81+
*/
82+
abstract fun update(@RequestBody model: T): Result<Boolean>
83+
84+
85+
/**
86+
* 批量删除
87+
*
88+
* @param ids ids
89+
* @return result
90+
*/
91+
abstract fun delByIds(@PathVariable ids: List<Long>): Result<Boolean>
92+
93+
}
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
package info.xiaomo.core.base;
1+
package info.xiaomo.core.base
22

3-
import org.springframework.data.jpa.repository.JpaRepository;
4-
import org.springframework.stereotype.Repository;
3+
import org.springframework.data.jpa.repository.JpaRepository
4+
import org.springframework.stereotype.Repository
55

66
/**
77
* @author : xiaomo (https://xiaomo.info) (https://github.com/xiaomoinfo)
88
* @version : 2017/1/13 11:23
99
*/
1010
@Repository
11-
public interface BaseDao<T> extends JpaRepository<T, Long> {
11+
interface BaseDao<T> : JpaRepository<T, Long> {
1212

1313
/**
1414
* 根据id查
1515
*
1616
* @param id
1717
* @return
1818
*/
19-
T findById(Long id);
19+
fun findById(id: Long?): T
2020

2121
/**
2222
* 根据名字查
2323
* @param name
2424
* @return
2525
*/
26-
T findByName(String name);
26+
fun findByName(name: String): T
2727

2828
/**
2929
* 删除
3030
* @param name
3131
* @return
3232
*/
33-
boolean deleteByName(String name);
33+
fun deleteByName(name: String): Boolean
3434
}
Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
package info.xiaomo.core.base;
1+
package info.xiaomo.core.base
22

3-
import lombok.Data;
4-
5-
import javax.persistence.*;
6-
import java.io.Serializable;
7-
import java.util.Date;
3+
import lombok.Data
4+
import java.io.Serializable
5+
import java.util.*
6+
import javax.persistence.*
87

98
/**
109
* 把今天最好的表现当作明天最新的起点..~
@@ -15,26 +14,38 @@
1514
* @author : xiaomo
1615
* github: https://github.com/xiaomoinfo
1716
* email: xiaomo@xiaomo.info
18-
17+
*
1918
* Date: 2016/4/1 20:37
2019
* Copyright(©) 2015 by xiaomo.
21-
**/
20+
*/
2221

2322
@MappedSuperclass
2423
@Data
25-
public abstract class BaseModel implements Serializable {
24+
abstract class BaseModel : Serializable {
2625

2726
@Id
2827
@GeneratedValue(strategy = GenerationType.AUTO)
2928
@Column(name = "Id")
30-
private Long id;
29+
var id: Long? = null
30+
set(id) {
31+
field = this.id
32+
}
3133

3234
@Column(name = "Name")
33-
private String name;
35+
var name: String? = null
36+
set(name) {
37+
field = this.name
38+
}
3439

3540
@Column(name = "CreateTime")
36-
private Date createTime;
41+
var createTime: Date? = null
42+
set(createTime) {
43+
field = this.createTime
44+
}
3745

3846
@Column(name = "UpdateTime")
39-
private Date updateTime;
47+
var updateTime: Date? = null
48+
set(updateTime) {
49+
field = this.updateTime
50+
}
4051
}

0 commit comments

Comments
 (0)