|
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody; |
|
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody; |
|
13
|
import org.springframework.web.bind.annotation.RequestMapping;
|
13
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
14
|
import org.springframework.web.bind.annotation.RestController;
|
14
|
import org.springframework.web.bind.annotation.RestController;
|
|
15
|
import com.ruoyi.common.core.controller.BaseController;
|
15
|
import com.ruoyi.common.core.controller.BaseController;
|
|
16
|
-import com.ruoyi.common.core.domain.AjaxResult;
|
16
|
+import com.ruoyi.common.core.domain.R;
|
|
17
|
import com.ruoyi.common.utils.StringUtils;
|
17
|
import com.ruoyi.common.utils.StringUtils;
|
|
18
|
import io.swagger.annotations.Api;
|
18
|
import io.swagger.annotations.Api;
|
|
19
|
import io.swagger.annotations.ApiImplicitParam;
|
19
|
import io.swagger.annotations.ApiImplicitParam;
|
|
@@ -40,24 +40,24 @@ public class TestController extends BaseController |
|
@@ -40,24 +40,24 @@ public class TestController extends BaseController |
|
40
|
|
40
|
|
|
41
|
@ApiOperation("获取用户列表")
|
41
|
@ApiOperation("获取用户列表")
|
|
42
|
@GetMapping("/list")
|
42
|
@GetMapping("/list")
|
|
43
|
- public AjaxResult userList()
|
43
|
+ public R<List<UserEntity>> userList()
|
|
44
|
{
|
44
|
{
|
|
45
|
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
45
|
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
|
46
|
- return AjaxResult.success(userList);
|
46
|
+ return R.ok(userList);
|
|
47
|
}
|
47
|
}
|
|
48
|
|
48
|
|
|
49
|
@ApiOperation("获取用户详细")
|
49
|
@ApiOperation("获取用户详细")
|
|
50
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
50
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
|
51
|
@GetMapping("/{userId}")
|
51
|
@GetMapping("/{userId}")
|
|
52
|
- public AjaxResult getUser(@PathVariable Integer userId)
|
52
|
+ public R<UserEntity> getUser(@PathVariable Integer userId)
|
|
53
|
{
|
53
|
{
|
|
54
|
if (!users.isEmpty() && users.containsKey(userId))
|
54
|
if (!users.isEmpty() && users.containsKey(userId))
|
|
55
|
{
|
55
|
{
|
|
56
|
- return AjaxResult.success(users.get(userId));
|
56
|
+ return R.ok(users.get(userId));
|
|
57
|
}
|
57
|
}
|
|
58
|
else
|
58
|
else
|
|
59
|
{
|
59
|
{
|
|
60
|
- return error("用户不存在");
|
60
|
+ return R.fail("用户不存在");
|
|
61
|
}
|
61
|
}
|
|
62
|
}
|
62
|
}
|
|
63
|
|
63
|
|
|
@@ -69,44 +69,46 @@ public class TestController extends BaseController |
|
@@ -69,44 +69,46 @@ public class TestController extends BaseController |
|
69
|
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
|
69
|
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
|
|
70
|
})
|
70
|
})
|
|
71
|
@PostMapping("/save")
|
71
|
@PostMapping("/save")
|
|
72
|
- public AjaxResult save(UserEntity user)
|
72
|
+ public R<String> save(UserEntity user)
|
|
73
|
{
|
73
|
{
|
|
74
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
74
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
|
75
|
{
|
75
|
{
|
|
76
|
- return error("用户ID不能为空");
|
76
|
+ return R.fail("用户ID不能为空");
|
|
77
|
}
|
77
|
}
|
|
78
|
- return AjaxResult.success(users.put(user.getUserId(), user));
|
78
|
+ users.put(user.getUserId(), user);
|
|
|
|
79
|
+ return R.ok();
|
|
79
|
}
|
80
|
}
|
|
80
|
|
81
|
|
|
81
|
@ApiOperation("更新用户")
|
82
|
@ApiOperation("更新用户")
|
|
82
|
@PutMapping("/update")
|
83
|
@PutMapping("/update")
|
|
83
|
- public AjaxResult update(@RequestBody UserEntity user)
|
84
|
+ public R<String> update(@RequestBody UserEntity user)
|
|
84
|
{
|
85
|
{
|
|
85
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
86
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
|
86
|
{
|
87
|
{
|
|
87
|
- return error("用户ID不能为空");
|
88
|
+ return R.fail("用户ID不能为空");
|
|
88
|
}
|
89
|
}
|
|
89
|
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
90
|
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
|
90
|
{
|
91
|
{
|
|
91
|
- return error("用户不存在");
|
92
|
+ return R.fail("用户不存在");
|
|
92
|
}
|
93
|
}
|
|
93
|
users.remove(user.getUserId());
|
94
|
users.remove(user.getUserId());
|
|
94
|
- return AjaxResult.success(users.put(user.getUserId(), user));
|
95
|
+ users.put(user.getUserId(), user);
|
|
|
|
96
|
+ return R.ok();
|
|
95
|
}
|
97
|
}
|
|
96
|
|
98
|
|
|
97
|
@ApiOperation("删除用户信息")
|
99
|
@ApiOperation("删除用户信息")
|
|
98
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
100
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
|
99
|
@DeleteMapping("/{userId}")
|
101
|
@DeleteMapping("/{userId}")
|
|
100
|
- public AjaxResult delete(@PathVariable Integer userId)
|
102
|
+ public R<String> delete(@PathVariable Integer userId)
|
|
101
|
{
|
103
|
{
|
|
102
|
if (!users.isEmpty() && users.containsKey(userId))
|
104
|
if (!users.isEmpty() && users.containsKey(userId))
|
|
103
|
{
|
105
|
{
|
|
104
|
users.remove(userId);
|
106
|
users.remove(userId);
|
|
105
|
- return success();
|
107
|
+ return R.ok();
|
|
106
|
}
|
108
|
}
|
|
107
|
else
|
109
|
else
|
|
108
|
{
|
110
|
{
|
|
109
|
- return error("用户不存在");
|
111
|
+ return R.fail("用户不存在");
|
|
110
|
}
|
112
|
}
|
|
111
|
}
|
113
|
}
|
|
112
|
}
|
114
|
}
|