riku
2019-09-11 a0694aba52b4fb590039ff69e1625938ebef1041
1.新增用户信息的获取存储接口
已修改1个文件
已添加5个文件
101 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/obd/lightshare/bean/ObdUserVo.kt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/lightshare/service/ObdUserService.kt 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/lightshare/service/impl/ObdUserServiceImpl.kt 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/lightshare/web/ObdUserController.kt 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/repository/ObdUserRepository.kt 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/repository/impl/ObdUserDaoImpl.kt 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/lightshare/bean/ObdUserVo.kt
@@ -10,5 +10,4 @@
    var obdVin: String? = null
    var obdUserId: Double? = null
    var obdUserName: String? = null
    var obdUserPassword: String? = null
}
src/main/kotlin/com/flightfeather/obd/lightshare/service/ObdUserService.kt
对比新文件
@@ -0,0 +1,13 @@
package com.flightfeather.obd.lightshare.service
import com.flightfeather.obd.lightshare.bean.ObdUserVo
/**
 * @author riku
 * Date: 2019/9/6
 */
interface ObdUserService {
    fun getUserInfo(userId: String): ObdUserVo?
}
src/main/kotlin/com/flightfeather/obd/lightshare/service/impl/ObdUserServiceImpl.kt
对比新文件
@@ -0,0 +1,18 @@
package com.flightfeather.obd.lightshare.service.impl
import com.flightfeather.obd.lightshare.bean.ObdUserVo
import com.flightfeather.obd.lightshare.service.ObdUserService
import com.flightfeather.obd.repository.ObdUserRepository
import org.springframework.stereotype.Service
/**
 * @author riku
 * Date: 2019/9/6
 */
@Service
class ObdUserServiceImpl(val userRepository: ObdUserRepository) :ObdUserService{
    override fun getUserInfo(userId: String): ObdUserVo? {
        return userRepository.getUserInfo(userId)
    }
}
src/main/kotlin/com/flightfeather/obd/lightshare/web/ObdUserController.kt
对比新文件
@@ -0,0 +1,22 @@
package com.flightfeather.obd.lightshare.web
import com.flightfeather.obd.lightshare.service.ObdUserService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
/**
 * @author riku
 * Date: 2019/9/6
 */
@RestController
@RequestMapping("obd/user")
class ObdUserController(val obdUserService: ObdUserService) {
    @GetMapping("/info/{userId}")
    fun getUserInfo(
            @PathVariable("userId") userId: String
    ) = obdUserService.getUserInfo(userId)
}
src/main/kotlin/com/flightfeather/obd/repository/ObdUserRepository.kt
对比新文件
@@ -0,0 +1,13 @@
package com.flightfeather.obd.repository
import com.flightfeather.obd.lightshare.bean.ObdUserVo
/**
 * @author riku
 * Date: 2019/9/6
 */
interface ObdUserRepository {
    fun getUserInfo(userId: String): ObdUserVo?
}
src/main/kotlin/com/flightfeather/obd/repository/impl/ObdUserDaoImpl.kt
对比新文件
@@ -0,0 +1,34 @@
package com.flightfeather.obd.repository.impl
import com.flightfeather.obd.domain.entity.ObdUser
import com.flightfeather.obd.domain.mapper.ObdUserMapper
import com.flightfeather.obd.lightshare.bean.ObdUserVo
import com.flightfeather.obd.repository.ObdUserRepository
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
/**
 * @author riku
 * Date: 2019/9/6
 */
@Repository
class ObdUserDaoImpl(val obdUserMapper: ObdUserMapper): ObdUserRepository {
    override fun getUserInfo(userId: String): ObdUserVo? {
        val example = Example(ObdUser::class.java).apply {
            createCriteria().andEqualTo("obdUserId", userId)
        }
        val result = obdUserMapper.selectByExample(example)
        if (result.isNotEmpty()) {
            val vo = ObdUserVo()
            BeanUtils.copyProperties(result[0], vo)
            return vo
        }
        return null
    }
}