@RestController @RequestMapping("/user") public class UserController { @Autowired private UserService userService; @RequestMapping("/findUser") public User findUser(){ return userService.findUser(); } @RequestMapping("/findUserById") public User findUserById(int userId){ User user = userService.findUserById(userId); System.out.println("123123123123123"+user.getUserName()); return user; } @RequestMapping("/addUser") public int addUser(User user){ System.out.println("12312312312312312312"+user.getUserName()); return userService.addUser(user); } @RequestMapping("/updateUser") public int updateUser(User user){ return userService.updateUser(user); } @RequestMapping("/deleteUser") public int deleteUser(int userId){ return userService.deleteUser(userId); }
}
public interface UserDao { @Select("select * from user where userId = '1'") User findUser(); @Select("select * from user where userId=#{userId}") User findUserById(int userId); @Insert("insert into user values(default,#{userName},#{userPassWord},#{userPhone})") int addUser(User user); @Update("update user set userName=#{userName},userPassWord=#{userPassWord},userPhone=#{userPhone} where userId=#{userId} ") int updateUser(User user); @Delete("delete from user where userId=#{userId}") int deleteUser(int userId); }