Skip to content

Commit

Permalink
Merge pull request #87 from jasonkung22/feat/inner-enum
Browse files Browse the repository at this point in the history
feat: Add an inner enum test example
  • Loading branch information
shalousun authored Nov 27, 2024
2 parents 5ebae99 + 2c38452 commit 84dcc2b
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.power.doc.controller;
package com.power.doc.controller.enums;

import com.power.common.model.CommonResult;
import com.power.doc.entity.Order;
Expand Down
119 changes: 119 additions & 0 deletions src/main/java/com/power/doc/controller/enums/InnerEnumController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package com.power.doc.controller.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import com.power.common.model.CommonResult;
import com.power.doc.entity.Order;
import com.power.doc.enums.GenderEnum;
import com.power.doc.enums.IEnum;
import com.power.doc.enums.OrderEnum;
import com.power.doc.enums.SimpleEnum;
import java.util.List;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* 内部枚举参数测试
* @author Jason Kung
* @date 2024/11/27 11:05
*/
@RestController
public class InnerEnumController {

/**
* 测试query参数枚举
* @param innerEnum 内部枚举
* @return 结果
*/
@GetMapping("/innerEnum/testQueryEnum")
public CommonResult<InnerEnum> testQueryEnum(@RequestParam InnerEnum innerEnum) {
return null;
}

/**
* 测试post参数枚举
* @param innerEnum 内部枚举
* @return 结果
*/
@PostMapping("/innerEnum/testPostEnum")
public CommonResult<InnerEnum> testPostEnum(@RequestParam InnerEnum innerEnum) {
return null;
}

/**
* 测试body参数枚举
* @param innerClass 内部类
* @return 结果
*/
@PostMapping("/innerEnum/testBodyEnum")
public CommonResult<InnerClass> testBodyEnum(@RequestBody InnerClass innerClass) {
return null;
}

/**
* 测试query+body参数枚举
* @param innerEnum 内部枚举参数
* @param innerClass 内部类
* @return 结果
*/
@PostMapping("/innerEnum/testBodyEnum")
public CommonResult<InnerClass> testQueryAndBodyEnum(@RequestParam InnerEnum innerEnum,
@RequestBody InnerClass innerClass) {
return null;
}

/**
* 内部类
*/
@Data
public static class InnerClass {

/**
* 内部参数
*/
private String innerParam;
/**
* 内部枚举参数
*/
private InnerEnum innerEnum;
}

/**
* 内部枚举
* @author jason 2024/11/27.
*/
public enum InnerEnum implements IEnum<Integer> {
/**
* 内部1
*/
INNER1(1, "内部1"),
/**
* 内部2
*/
INNER2(2, "内部2");

private int code;

private String desc;

InnerEnum(int code, String desc) {
this.code = code;
this.desc = desc;
}

@Override
@JsonValue
public Integer getCode() {
return this.code;
}

@Override
public String getDesc() {
return desc;
}
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/power/doc/word/WordTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private ApiConfig config(boolean isAll) {

ApiGroup apiGroup = new ApiGroup();
apiGroup.setName("测试分组1");
apiGroup.setApis("com.power.doc.controller.EnumController");
apiGroup.setApis("com.power.doc.controller.enums.EnumController");
ApiGroup apiGroup1 = new ApiGroup();
apiGroup1.setName("测试分组2");
apiGroup1.setApis("com.power.doc.controller.FormDataController");
Expand Down

0 comments on commit 84dcc2b

Please sign in to comment.