Java接收带List的实体类
@PostMapping("/add") @ApiOperation(value = "新增价格联动补贴信息",notes = "param") public MessageTo<String> addPriceAllowance(@RequestBody PriceAllowanceParam param) throws InvalidSystemClockException { return priceAllowanceInfoService.addPriceAllowance(param); } //实体类 package com.panchina.adjustment.domain.param; import com.panchina.adjustment.domain.entity.PriceAllowanceDetail; import lombok.Data; import java.math.BigDecimal; import java.util.List; @Data public class PriceAllowanceParam { private Long id; private Integer yearIndex; private Integer monthIndex; private String remark; private String areaCode; private BigDecimal cpi; private BigDecimal foodPriceIndex; private BigDecimal scpi; private BigDecimal paymentAmount; private Integer paymentTime; private Integer minimumStandard; private Integer highestStandard; private List<PriceAllowanceDetail> allowanceDetails; }
前端调用
form: { yearIndex: "", monthIndex: "", areaCode: "", cpi: "", foodPriceIndex: "", scpi: "", paymentAmount: "", paymentTime: "", minimumStandard: "", highestStandard: "", remark: "", allowanceDetails: [ { issueObject: "城镇最低生活保障对象", paymentAmount: 0, paymentTime: "0", minimumStandard: "0", highestStandard: "0", remark: "", sort: 1 }, { issueObject: "农村最低生活保障对象", paymentAmount: 0, paymentTime: "0", minimumStandard: "0", highestStandard: "0", remark: "", sort: 2 } ] } addPriceAllowance() { this.$refs.form.validate(valid => { if (valid) { let data = JSON.stringify(this.form); if (this.form.id == "" || this.form.id == undefined) { axios({ method: "post", //请求方式 url: "/price-adjustment/api/priceAllowance/add", //请求地址 headers: { "Content-Type": "application/json;charset=UTF-8" }, data: data }) .then(res => { if (res.data.success) { this.$router.push("/subsidy"); } }) .catch(err => {}); } } else { console.log("error"); } }); }