| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.R;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiImplicitParam;
|
| | | import io.swagger.annotations.ApiImplicitParams;
|
| | | import io.swagger.annotations.ApiModel;
|
| | | import io.swagger.annotations.ApiModelProperty;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
|
| | | /**
|
| | | * swagger 用户测试方法
|
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | @Api("用户信息管理")
|
| | | @Tag(name = "用户信息管理")
|
| | | @RestController
|
| | | @RequestMapping("/test/user")
|
| | | public class TestController extends BaseController
|
| | |
| | | users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
|
| | | }
|
| | |
|
| | | @ApiOperation("获取用户列表")
|
| | | @Operation(summary = "获取用户列表")
|
| | | @GetMapping("/list")
|
| | | public R<List<UserEntity>> userList()
|
| | | {
|
| | |
| | | return R.ok(userList);
|
| | | }
|
| | |
|
| | | @ApiOperation("获取用户详细")
|
| | | @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
| | | @GetMapping("/{userId}")
|
| | | public R<UserEntity> getUser(@PathVariable Integer userId)
|
| | | @Operation(summary = "获取用户详细")
|
| | | @Parameter(name = "userId", description = "用户ID", required = true) |
| | | @GetMapping("/{userId}") |
| | | public R<UserEntity> getUser(@PathVariable Integer userId) |
| | | {
|
| | | if (!users.isEmpty() && users.containsKey(userId))
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @ApiOperation("新增用户")
|
| | | @ApiImplicitParams({
|
| | | @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
|
| | | @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
|
| | | @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
|
| | | @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
|
| | | })
|
| | | @PostMapping("/save")
|
| | | public R<String> save(UserEntity user)
|
| | | @Operation(summary = "新增用户")
|
| | | @Parameters({ |
| | | @Parameter(name = "userId", description = "用户id"), |
| | | @Parameter(name = "username", description = "用户名称"), |
| | | @Parameter(name = "password", description = "用户密码"), |
| | | @Parameter(name = "mobile", description = "用户手机") |
| | | }) |
| | | @PostMapping("/save") |
| | | public R<String> save(UserEntity user) |
| | | {
|
| | | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
| | | {
|
| | |
| | | return R.ok();
|
| | | }
|
| | |
|
| | | @ApiOperation("更新用户")
|
| | | @Operation(summary = "更新用户")
|
| | | @PutMapping("/update")
|
| | | public R<String> update(@RequestBody UserEntity user)
|
| | | {
|
| | |
| | | return R.ok();
|
| | | }
|
| | |
|
| | | @ApiOperation("删除用户信息")
|
| | | @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
| | | @DeleteMapping("/{userId}")
|
| | | public R<String> delete(@PathVariable Integer userId)
|
| | | @Operation(summary = "删除用户信息")
|
| | | @Parameter(name = "userId", description = "用户ID", required = true) |
| | | @DeleteMapping("/{userId}") |
| | | public R<String> delete(@PathVariable Integer userId) |
| | | {
|
| | | if (!users.isEmpty() && users.containsKey(userId))
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @ApiModel(value = "UserEntity", description = "用户实体")
|
| | | @Schema(name = "UserEntity", description = "用户实体")
|
| | | class UserEntity
|
| | | {
|
| | | @ApiModelProperty("用户ID")
|
| | | @Schema(description = "用户ID")
|
| | | private Integer userId;
|
| | |
|
| | | @ApiModelProperty("用户名称")
|
| | | @Schema(description = "用户名称")
|
| | | private String username;
|
| | |
|
| | | @ApiModelProperty("用户密码")
|
| | | @Schema(description = "用户密码")
|
| | | private String password;
|
| | |
|
| | | @ApiModelProperty("用户手机")
|
| | | @Schema(description = "用户手机")
|
| | | private String mobile;
|
| | |
|
| | | public UserEntity()
|