| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,8 +25,8 @@ import org.springframework.web.bind.annotation.RestController | |||
| 25 | 25 | ||
| 26 | 26 | @RestController | |
| 27 | 27 | @RequestMapping("/") | |
| 28 | - class TestController @Autowired | ||
| 29 | - constructor(private val task: AsyncTask) { | ||
| 28 | + class TestController | ||
| 29 | + @Autowired constructor(private val task: AsyncTask) { | ||
| 30 | 30 | ||
| 31 | 31 | @RequestMapping(value = "/", method = arrayOf(RequestMethod.GET)) | |
| 32 | 32 | @Throws(Exception::class) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,13 @@ | |||
| 1 | - package info.xiaomo.core.base; | ||
| 1 | + package info.xiaomo.core.base | ||
| 2 | 2 | ||
| 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.* | ||
| 6 | 5 | ||
| 7 | 6 | /** | |
| 8 | 7 | * @author : xiaomo (https://xiaomo.info) (https://github.com/xiaomoinfo) | |
| 9 | 8 | * @version : 2017/1/13 9:51 | |
| 10 | 9 | */ | |
| 11 | - public interface AuthOperate { | ||
| 10 | + interface AuthOperate { | ||
| 12 | 11 | ||
| 13 | 12 | ||
| 14 | 13 | /** | |
@@ -18,7 +17,7 @@ public interface AuthOperate { | |||
| 18 | 17 | * @param password 密码 | |
| 19 | 18 | * @return 结果 | |
| 20 | 19 | */ | |
| 21 | - Result<Boolean> login(@PathVariable String name, @PathVariable String password); | ||
| 20 | + fun login(@PathVariable name: String, @PathVariable password: String): Result<Boolean> | ||
| 22 | 21 | ||
| 23 | 22 | ||
| 24 | 23 | /** | |
@@ -28,7 +27,7 @@ public interface AuthOperate { | |||
| 28 | 27 | * @param password 密码 | |
| 29 | 28 | * @return 结果 | |
| 30 | 29 | */ | |
| 31 | - Result<Boolean> changePassword(@PathVariable String name, @PathVariable String password); | ||
| 30 | + fun changePassword(@PathVariable name: String, @PathVariable password: String): Result<Boolean> | ||
| 32 | 31 | ||
| 33 | 32 | /** | |
| 34 | 33 | * 注册 | |
@@ -37,7 +36,7 @@ public interface AuthOperate { | |||
| 37 | 36 | * @param password 密码 | |
| 38 | 37 | * @return 是否己发送验证码 | |
| 39 | 38 | */ | |
| 40 | - Result<Boolean> register(@PathVariable String name, @PathVariable String password); | ||
| 39 | + fun register(@PathVariable name: String, @PathVariable password: String): Result<Boolean> | ||
| 41 | 40 | ||
| 42 | 41 | /** | |
| 43 | 42 | * 验证 | |
@@ -46,6 +45,6 @@ public interface AuthOperate { | |||
| 46 | 45 | * @param time 发送时间 | |
| 47 | 46 | * @return 是否验证通过 | |
| 48 | 47 | */ | |
| 49 | - Result<Boolean> validate(@PathVariable int validCode, @PathVariable Date time); | ||
| 48 | + fun validate(@PathVariable validCode: Int, @PathVariable time: Date): Result<Boolean> | ||
| 50 | 49 | ||
| 51 | 50 | } | |
| Original file line number | Diff line number | Diff 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 number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,34 +1,34 @@ | |||
| 1 | - package info.xiaomo.core.base; | ||
| 1 | + package info.xiaomo.core.base | ||
| 2 | 2 | ||
| 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 | ||
| 5 | 5 | ||
| 6 | 6 | /** | |
| 7 | 7 | * @author : xiaomo (https://xiaomo.info) (https://github.com/xiaomoinfo) | |
| 8 | 8 | * @version : 2017/1/13 11:23 | |
| 9 | 9 | */ | |
| 10 | 10 | @Repository | |
| 11 | - public interface BaseDao<T> extends JpaRepository<T, Long> { | ||
| 11 | + interface BaseDao<T> : JpaRepository<T, Long> { | ||
| 12 | 12 | ||
| 13 | 13 | /** | |
| 14 | 14 | * 根据id查 | |
| 15 | 15 | * | |
| 16 | 16 | * @param id | |
| 17 | 17 | * @return | |
| 18 | 18 | */ | |
| 19 | - T findById(Long id); | ||
| 19 | + fun findById(id: Long?): T | ||
| 20 | 20 | ||
| 21 | 21 | /** | |
| 22 | 22 | * 根据名字查 | |
| 23 | 23 | * @param name | |
| 24 | 24 | * @return | |
| 25 | 25 | */ | |
| 26 | - T findByName(String name); | ||
| 26 | + fun findByName(name: String): T | ||
| 27 | 27 | ||
| 28 | 28 | /** | |
| 29 | 29 | * 删除 | |
| 30 | 30 | * @param name | |
| 31 | 31 | * @return | |
| 32 | 32 | */ | |
| 33 | - boolean deleteByName(String name); | ||
| 33 | + fun deleteByName(name: String): Boolean | ||
| 34 | 34 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,9 @@ | |||
| 1 | - package info.xiaomo.core.base; | ||
| 1 | + package info.xiaomo.core.base | ||
| 2 | 2 | ||
| 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.* | ||
| 8 | 7 | ||
| 9 | 8 | /** | |
| 10 | 9 | * 把今天最好的表现当作明天最新的起点..~ | |
@@ -15,26 +14,38 @@ | |||
| 15 | 14 | * @author : xiaomo | |
| 16 | 15 | * github: https://github.com/xiaomoinfo | |
| 17 | 16 | * email: xiaomo@xiaomo.info | |
| 18 | - | ||
| 17 | + * | ||
| 19 | 18 | * Date: 2016/4/1 20:37 | |
| 20 | 19 | * Copyright(©) 2015 by xiaomo. | |
| 21 | - **/ | ||
| 20 | + */ | ||
| 22 | 21 | ||
| 23 | 22 | @MappedSuperclass | |
| 24 | 23 | @Data | |
| 25 | - public abstract class BaseModel implements Serializable { | ||
| 24 | + abstract class BaseModel : Serializable { | ||
| 26 | 25 | ||
| 27 | 26 | @Id | |
| 28 | 27 | @GeneratedValue(strategy = GenerationType.AUTO) | |
| 29 | 28 | @Column(name = "Id") | |
| 30 | - private Long id; | ||
| 29 | + var id: Long? = null | ||
| 30 | + set(id) { | ||
| 31 | + field = this.id | ||
| 32 | + } | ||
| 31 | 33 | ||
| 32 | 34 | @Column(name = "Name") | |
| 33 | - private String name; | ||
| 35 | + var name: String? = null | ||
| 36 | + set(name) { | ||
| 37 | + field = this.name | ||
| 38 | + } | ||
| 34 | 39 | ||
| 35 | 40 | @Column(name = "CreateTime") | |
| 36 | - private Date createTime; | ||
| 41 | + var createTime: Date? = null | ||
| 42 | + set(createTime) { | ||
| 43 | + field = this.createTime | ||
| 44 | + } | ||
| 37 | 45 | ||
| 38 | 46 | @Column(name = "UpdateTime") | |
| 39 | - private Date updateTime; | ||
| 47 | + var updateTime: Date? = null | ||
| 48 | + set(updateTime) { | ||
| 49 | + field = this.updateTime | ||
| 50 | + } | ||
| 40 | 51 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments