正在显示
1 个修改的文件
包含
16 行增加
和
10 行删除
| @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping; | @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping; | ||
| 9 | import org.springframework.web.bind.annotation.PathVariable; | 9 | import org.springframework.web.bind.annotation.PathVariable; |
| 10 | import org.springframework.web.bind.annotation.PostMapping; | 10 | import org.springframework.web.bind.annotation.PostMapping; |
| 11 | import org.springframework.web.bind.annotation.PutMapping; | 11 | import org.springframework.web.bind.annotation.PutMapping; |
| 12 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 12 | import org.springframework.web.bind.annotation.RequestMapping; | 13 | import org.springframework.web.bind.annotation.RequestMapping; |
| 13 | import org.springframework.web.bind.annotation.RestController; | 14 | import org.springframework.web.bind.annotation.RestController; |
| 14 | import com.ruoyi.common.core.controller.BaseController; | 15 | import com.ruoyi.common.core.controller.BaseController; |
| @@ -16,6 +17,7 @@ import com.ruoyi.common.core.domain.AjaxResult; | @@ -16,6 +17,7 @@ import com.ruoyi.common.core.domain.AjaxResult; | ||
| 16 | import com.ruoyi.common.utils.StringUtils; | 17 | import com.ruoyi.common.utils.StringUtils; |
| 17 | import io.swagger.annotations.Api; | 18 | import io.swagger.annotations.Api; |
| 18 | import io.swagger.annotations.ApiImplicitParam; | 19 | import io.swagger.annotations.ApiImplicitParam; |
| 20 | +import io.swagger.annotations.ApiImplicitParams; | ||
| 19 | import io.swagger.annotations.ApiModel; | 21 | import io.swagger.annotations.ApiModel; |
| 20 | import io.swagger.annotations.ApiModelProperty; | 22 | import io.swagger.annotations.ApiModelProperty; |
| 21 | import io.swagger.annotations.ApiOperation; | 23 | import io.swagger.annotations.ApiOperation; |
| @@ -55,34 +57,38 @@ public class TestController extends BaseController | @@ -55,34 +57,38 @@ public class TestController extends BaseController | ||
| 55 | } | 57 | } |
| 56 | else | 58 | else |
| 57 | { | 59 | { |
| 58 | - return AjaxResult.error("用户不存在"); | 60 | + return error("用户不存在"); |
| 59 | } | 61 | } |
| 60 | } | 62 | } |
| 61 | 63 | ||
| 62 | @ApiOperation("新增用户") | 64 | @ApiOperation("新增用户") |
| 63 | - @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") | 65 | + @ApiImplicitParams({ |
| 66 | + @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer"), | ||
| 67 | + @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String"), | ||
| 68 | + @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String"), | ||
| 69 | + @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String") | ||
| 70 | + }) | ||
| 64 | @PostMapping("/save") | 71 | @PostMapping("/save") |
| 65 | public AjaxResult save(UserEntity user) | 72 | public AjaxResult save(UserEntity user) |
| 66 | { | 73 | { |
| 67 | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) | 74 | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) |
| 68 | { | 75 | { |
| 69 | - return AjaxResult.error("用户ID不能为空"); | 76 | + return error("用户ID不能为空"); |
| 70 | } | 77 | } |
| 71 | return AjaxResult.success(users.put(user.getUserId(), user)); | 78 | return AjaxResult.success(users.put(user.getUserId(), user)); |
| 72 | } | 79 | } |
| 73 | 80 | ||
| 74 | @ApiOperation("更新用户") | 81 | @ApiOperation("更新用户") |
| 75 | - @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") | ||
| 76 | @PutMapping("/update") | 82 | @PutMapping("/update") |
| 77 | - public AjaxResult update(UserEntity user) | 83 | + public AjaxResult update(@RequestBody UserEntity user) |
| 78 | { | 84 | { |
| 79 | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) | 85 | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) |
| 80 | { | 86 | { |
| 81 | - return AjaxResult.error("用户ID不能为空"); | 87 | + return error("用户ID不能为空"); |
| 82 | } | 88 | } |
| 83 | if (users.isEmpty() || !users.containsKey(user.getUserId())) | 89 | if (users.isEmpty() || !users.containsKey(user.getUserId())) |
| 84 | { | 90 | { |
| 85 | - return AjaxResult.error("用户不存在"); | 91 | + return error("用户不存在"); |
| 86 | } | 92 | } |
| 87 | users.remove(user.getUserId()); | 93 | users.remove(user.getUserId()); |
| 88 | return AjaxResult.success(users.put(user.getUserId(), user)); | 94 | return AjaxResult.success(users.put(user.getUserId(), user)); |
| @@ -96,16 +102,16 @@ public class TestController extends BaseController | @@ -96,16 +102,16 @@ public class TestController extends BaseController | ||
| 96 | if (!users.isEmpty() && users.containsKey(userId)) | 102 | if (!users.isEmpty() && users.containsKey(userId)) |
| 97 | { | 103 | { |
| 98 | users.remove(userId); | 104 | users.remove(userId); |
| 99 | - return AjaxResult.success(); | 105 | + return success(); |
| 100 | } | 106 | } |
| 101 | else | 107 | else |
| 102 | { | 108 | { |
| 103 | - return AjaxResult.error("用户不存在"); | 109 | + return error("用户不存在"); |
| 104 | } | 110 | } |
| 105 | } | 111 | } |
| 106 | } | 112 | } |
| 107 | 113 | ||
| 108 | -@ApiModel("用户实体") | 114 | +@ApiModel(value = "UserEntity", description = "用户实体") |
| 109 | class UserEntity | 115 | class UserEntity |
| 110 | { | 116 | { |
| 111 | @ApiModelProperty("用户ID") | 117 | @ApiModelProperty("用户ID") |
-
请 注册 或 登录 后发表评论