提交 b99b2819 authored 作者: shaotianyang's avatar shaotianyang

4th commit

上级 1c9ff3b0
...@@ -2,10 +2,7 @@ package com.ai.controller; ...@@ -2,10 +2,7 @@ package com.ai.controller;
import com.ai.service.UserService; import com.ai.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@CrossOrigin @CrossOrigin
...@@ -21,4 +18,9 @@ public class UserController { ...@@ -21,4 +18,9 @@ public class UserController {
return userService.findAllUser().toString(); return userService.findAllUser().toString();
} }
@GetMapping("/findUserById/{id}")
public String findUserById(@PathVariable Long id){
return userService.findUserById(id).toString();
}
} }
...@@ -8,4 +8,6 @@ public interface UserMapper { ...@@ -8,4 +8,6 @@ public interface UserMapper {
List<User> findAllUser(); List<User> findAllUser();
User findUserById(Long id);
} }
...@@ -8,4 +8,6 @@ public interface UserService { ...@@ -8,4 +8,6 @@ public interface UserService {
List<User> findAllUser(); List<User> findAllUser();
User findUserById(Long id);
} }
...@@ -19,4 +19,11 @@ public class UserServiceImpl implements UserService { ...@@ -19,4 +19,11 @@ public class UserServiceImpl implements UserService {
return mapper.findAllUser(); return mapper.findAllUser();
} }
@Override
public User findUserById(Long id) {
SqlSession sqlSession = MyBatisUtils.getSqlSession();
UserMapper mapper = sqlSession.getMapper(UserMapper.class);
return mapper.findUserById(1L);
}
} }
...@@ -6,7 +6,13 @@ ...@@ -6,7 +6,13 @@
<select id="findAllUser" resultType="com.ai.pojo.User"> <select id="findAllUser" resultType="com.ai.pojo.User">
select * select *
from user; from user
</select>
<select id="findUserById" resultType="com.ai.pojo.User">
select *
from user
where id = #{id}
</select> </select>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论