diff --git a/src/main/java/com/haiyang/boot/controller/UserController.java b/src/main/java/com/haiyang/boot/controller/UserController.java index eabd6a88e9c5a332e9a327e6c5d3efb86e48e2b8..d9c89e34111545f07f793bc4c6f4c4739a2ad365 100644 --- a/src/main/java/com/haiyang/boot/controller/UserController.java +++ b/src/main/java/com/haiyang/boot/controller/UserController.java @@ -1,6 +1,5 @@ package com.haiyang.boot.controller; -import com.haiyang.boot.domain.User; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -10,9 +9,7 @@ public class UserController { @GetMapping("/user") public User getUser() { - User user = new User(); - user.setName("haiyang"); - user.setAge("18"); + User user = new User("1", 20); return user; } } diff --git a/src/main/java/com/haiyang/boot/domain/User.java b/src/main/java/com/haiyang/boot/domain/User.java index 2eecc9e989bd25d3618afad21c0b1f2d69aa09c4..8c23c1d4f36ab7ba218b43be01454b0ed20025f4 100644 --- a/src/main/java/com/haiyang/boot/domain/User.java +++ b/src/main/java/com/haiyang/boot/domain/User.java @@ -16,6 +16,11 @@ public class User { return age; } + public User(String name, String age) { + this.name = name; + this.age = age; + } + public void setAge(String age) { this.age = age; }