Bläddra i källkod

api文件添加响应参数

wuweihao 5 år sedan
förälder
incheckning
6557a21359

+ 6 - 5
museum_domain/src/main/java/com/museum/domain/entity/UserEntity.java

@@ -1,6 +1,7 @@
 package com.museum.domain.entity;
 
 import com.alibaba.fastjson.annotation.JSONField;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import javax.persistence.Table;
@@ -16,6 +17,7 @@ public class UserEntity extends BaseEntity implements Serializable {
     private static final long serialVersionUID = -5191918184688236778L;
 
     /** 用户名 */
+    @ApiModelProperty(value = "用户名")
     private String userName;
 
     /** 真实姓名 */
@@ -27,19 +29,18 @@ public class UserEntity extends BaseEntity implements Serializable {
     /** 性别 0:男  1:女 */
 //    private Integer sex;
 
-    /** 电话 */
+    @ApiModelProperty(value = "电话")
     private String phone;
 
-    /** 邮箱 */
     @JSONField(serialize = false)
 //    private String email;
 
-    /** 状态 0:启用  1:停用 2:注销 */
+    @ApiModelProperty(value = "状态 0:启用  1:停用 2:注销")
     private Integer status;
 
-    /** 角色:只有两种 admin normal  */
+    @ApiModelProperty(value = "角色:只有两种 admin:超级管理员, normal:普通管理员")
     private String role;
 
-    /** 头像 */
+    @ApiModelProperty(value = "头像,base64")
     private String ico;
 }

+ 2 - 2
museum_web/src/main/java/com/museum/web/controller/UserController.java

@@ -49,7 +49,7 @@ public class UserController extends BaseController {
     @RequiresRoles(value = {"admin"}, logical = Logical.OR)
     @ApiOperation("用户列表")
     @PostMapping("list")
-    public Result list(@RequestBody PageRequest param) {
+    public Result<UserEntity> list(@RequestBody PageRequest param) {
         startPage(param);
         PageInfo<UserEntity> page = new PageInfo<>(userService.findBySearchKey(param));
         return Result.success(page);
@@ -88,7 +88,7 @@ public class UserController extends BaseController {
 
     @ApiOperation("查询用户信息")
     @GetMapping("detail/{id}")
-    public Result detail(@PathVariable Long id) {
+    public Result<UserEntity> detail(@PathVariable Long id) {
         UserEntity user = userService.findById(id);
 
         if (user == null) {