我的列舉類代碼
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/*
* @description:交易型別列舉類
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@ApiModel("交易型別列舉")
public enum TransactionType implements IEnum<Integer> {
receivable(11, "應收"),
receipt(12, "收款"),
payable(13, "應付"),
payment(14, "付款"),
otherReceipt(21, "其他收款"),
otherPayment(22, "其他付款"),
accountTransfer(31, "轉賬"),
accountAdjustment(32, "賬戶調整");
private int value;
@ApiModelProperty("交易名稱")
private String desc;
TransactionType(int value, String desc) {
this.value = value;
this.desc = desc;
}
@Override
public Integer getValue() {
return value;
}
public String getDesc() {
return desc;
}
public static TransactionType getByValue(int value) {
for (TransactionType transactionType : values()) {
if (transactionType.getValue() == value) {
return transactionType;
}
}
return null;
}
}
我的介面請求物件
public class FinancialTypeQuery extends BaseTenantInfo {
private static final long serialVersionUID = 3796292091036079412L;
@ApiModelProperty("交易型別")
@JsonFormat(shape = JsonFormat.Shape.STRING)
private TransactionType transactionType;
@ApiModelProperty("父型別編號")
private Long parentSn;
@ApiModelProperty("編號")
private Long sn;
@ApiModelProperty("型別名稱")
private String name;
@ApiModelProperty(value = "型別串列" ,hidden = true)
@JsonFormat(shape = JsonFormat.Shape.ARRAY)
private List<TransactionType> transactionTypes;
}我的controller代碼
@RestController
@RequestMapping("/finance/financialType")
@Setter(onMethod_ = {@Autowired})
@Api(tags = "財務型別介面")
public class FinancialTypeRest {
private FinancialTypeService financialTypeService;
@GetMapping(value = "/page")
@ApiOperation(value = "財務型別分頁查詢")
@Auth(permissions = {PermissionType.finance_setting})
public ApiResponses<Page<FinancialType>> page(FinancialTypePageQuery financialTypePageQuery) {
return ApiResponses.success(financialTypeService.page(financialTypePageQuery));
}
}

為了減少代碼我刪了幾個欄位只留了transactionType和transactionTypes,回傳是正常的,將TransactionType物件json化了,但是請求的顯示就亂了,前端無法看懂.請問我該怎么辦?
我使用了swagger2,參考方式是單引一個knife4j的包,版本是2.0.8
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.8</version>
</dependency>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/247464.html
標籤:Web 開發
