From a0694aba52b4fb590039ff69e1625938ebef1041 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期三, 11 九月 2019 16:19:22 +0800 Subject: [PATCH] 1.新增用户信息的获取存储接口 --- src/main/kotlin/com/flightfeather/obd/lightshare/web/ObdUserController.kt | 22 +++++++++++ src/main/kotlin/com/flightfeather/obd/repository/impl/ObdUserDaoImpl.kt | 34 +++++++++++++++++ src/main/kotlin/com/flightfeather/obd/lightshare/bean/ObdUserVo.kt | 1 src/main/kotlin/com/flightfeather/obd/lightshare/service/ObdUserService.kt | 13 ++++++ src/main/kotlin/com/flightfeather/obd/lightshare/service/impl/ObdUserServiceImpl.kt | 18 +++++++++ src/main/kotlin/com/flightfeather/obd/repository/ObdUserRepository.kt | 13 ++++++ 6 files changed, 100 insertions(+), 1 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/obd/lightshare/bean/ObdUserVo.kt b/src/main/kotlin/com/flightfeather/obd/lightshare/bean/ObdUserVo.kt index 19a99e9..ebc2f13 100644 --- a/src/main/kotlin/com/flightfeather/obd/lightshare/bean/ObdUserVo.kt +++ b/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 } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/obd/lightshare/service/ObdUserService.kt b/src/main/kotlin/com/flightfeather/obd/lightshare/service/ObdUserService.kt new file mode 100644 index 0000000..f486496 --- /dev/null +++ b/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? + +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/obd/lightshare/service/impl/ObdUserServiceImpl.kt b/src/main/kotlin/com/flightfeather/obd/lightshare/service/impl/ObdUserServiceImpl.kt new file mode 100644 index 0000000..18292f9 --- /dev/null +++ b/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) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/obd/lightshare/web/ObdUserController.kt b/src/main/kotlin/com/flightfeather/obd/lightshare/web/ObdUserController.kt new file mode 100644 index 0000000..9cb6d21 --- /dev/null +++ b/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) + +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/obd/repository/ObdUserRepository.kt b/src/main/kotlin/com/flightfeather/obd/repository/ObdUserRepository.kt new file mode 100644 index 0000000..4ecbed1 --- /dev/null +++ b/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? + +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/obd/repository/impl/ObdUserDaoImpl.kt b/src/main/kotlin/com/flightfeather/obd/repository/impl/ObdUserDaoImpl.kt new file mode 100644 index 0000000..56bb715 --- /dev/null +++ b/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 + } + +} \ No newline at end of file -- Gitblit v1.9.3