1. 数组类型传参
后端写法:
@ApiOperation(value = "试卷中新增题目(多个直接覆盖)", notes="试卷中新增题目(多个直接覆盖)")
@ApiImplicitParams({
@ApiImplicitParam(name="examId",value="试卷id"),
@ApiImplicitParam(name="questionIdList[]",value="试题id集合"),
})
@RequiresPermissions({"training_exam_edit"})
@Log(title="试卷中新增题目(多个直接覆盖)", type=LogConstans.type_opt_edit, module=LogConstans.ADMIN)
@RepeatUrlFormData
@ResponseBody
@RequestMapping(value = "updateExamQuestionList", method=RequestMethod.POST)
public ResponseData<Integer> updateExamQuestionList(@RequestParam("examId")Long examId, @RequestParam("questionIdList[]")List<Long> questionIdList) {
this.logger.info("{}-试卷中新增题目,examId:{}-queationIdList:{}" , info_prefix, examId, questionIdList);
ResponseData<Integer> r = new ResponseData<Integer>(ResponseStateEnum.success);
Long adminId = JWTUtil.getCurrentAccountId();
examServiceByPlatformAdmin.updateExamQuestionList(examId, questionIdList, adminId);
r.setContent("试卷中新增题目 成功!");
return r;
}
前端写法:
//form-data表单方式提交,以下是参数表
//若去掉"[]"变为"questionIdList:xxx,XXXX"的话,后端也需要对应去掉"[]"
examId:98723966985776597
questionIdList[]:98723966985776590,98723966985773115,98723966985773116,98723966985773120,98723966985773121,98723966985773124,98723966985773126,98723966985773128,98723966985773091,98723966985773094
2.List<Object>对象集合传参
后端写法:
@ApiOperation(value = "用户答题接口", notes="用户答题接口")
@ResponseBody
@RequestMapping(value = "/addUserExamQuestionList", method = RequestMethod.POST)
public ResponseAppData<String> addUserExamQuestionList(@RequestBody List<UserExamQuestionModel> userExamQuestionModelList) {
Long userId = AppUserUtils.getCurrentUser().getUserId();
logger.info("{}-用户答题接口 , userId:{}-userExamQuestionModelList:{}", info_prefix, userId, userExamQuestionModelList);
ResponseAppData<String> r = new ResponseAppData<String>();
//添加 用户-题目-答题信息(答题过程数据insert)
examServiceByApp.addUserExamQuestionList(userExamQuestionModelList, userId);
r.setmsg("当前试题答题 成功!");
return r;
}
前端/APP端写法
//json方式提交
[{"examId":"98723966985717702","questionId":"98697600399590027","answer":"A","fillAnswer":""},
{"examId":"98723966985717702","questionId":"98697600399590038","answer":"C","fillAnswer":""},
{"examId":"98723966985717702","questionId":"98697600399590038","answer":"C","fillAnswer":""},
{"examId":"98723966985717702","questionId":"98697600399590045","answer":"A","fillAnswer":""},
{"examId":"98723966985717702","questionId":"98697600399590055","answer":"A","fillAnswer":""}]
3. 数组类型传参
后端写法:
@ApiOperation(value="批量更新状态")
@ApiImplicitParams({
@ApiImplicitParam(name="idArr[]",value="人才理念id集合"),
@ApiImplicitParam(name="status",value="状态标志位(1:草稿;2:发布)"),
})
@Log(title="更新人才理念状态", type=LogConstans.type_opt, module=LogConstans.other)
@RepeatUrlFormData
@RequiresPermissions({"talent_concept_edit"})
@RequestMapping(value = "batchSaveStatus", method = RequestMethod.POST)
public ResponseData<String> batchSaveStatus(Long[] idArr, Integer status){
}
前端写法:
//form/data提交方式
idArr: 1,
idArr: 2,
status: 1