swagger同时传递实体类型,List+Multipart⽂件的解决⽅法
1.不加Multipart⽂件的正确传输⽅法
@ApiImplicitParams({
@ApiImplicitParam(type ="query",name ="name",value ="⾓⾊名",required = true),
@ApiImplicitParam(type ="query", name ="remark",value ="⾓⾊备注",required = true),
@ApiImplicitParam(type ="query", name ="createBy",value ="创建者",required = true),
})
@PostMapping("/register")
public HttpResult upload(SysRole sysRole, @RequestBody List<Long> menus){
2.不加List⽂件的正确传输⽅法
@ApiImplicitParams({
@ApiImplicitParam(type ="query",name ="name",value ="机构名",required = true),
param name@ApiImplicitParam(type ="query",name ="parentId",value ="上级机构ID,⼀级机构为0",required = true),
@ApiImplicitParam(type ="query",name ="createBy",value ="创建⼈",required = true)
})
@PostMapping("/register")
public HttpResult upload(SysDept sysDept, @ApiParam("uploadFile")MultipartFile uploadFile) throws FileNotFoundException {
3.同时添加List以及Multipart⽂件的正确传输⽅法:放弃实体类⾃动映射
@ApiImplicitParams({
@ApiImplicitParam(type ="query", name ="name",value ="⽤户名",required = true),
@ApiImplicitParam(type ="query", name ="password",value ="密码",required = true),
@ApiImplicitParam(type ="query", name ="deptId",value ="所属⽅向ID",required = true),
@ApiImplicitParam(type ="query", name ="grade",value ="年级,⽐如2018",required = true),
@ApiImplicitParam(type ="query", name ="email",value ="邮箱,确保格式正确",required = true),
@ApiImplicitParam(type ="query", name ="mobile",value ="⼿机,确保格式正确",required = true),
// @ApiImplicitParam(name = "uploadFile",value = "上传⽂件",dataType = "File",paramType = "form"),
// @ApiImplicitParam(name = "roleList", value = "⾓⾊列表",dataType = "List", paramType = "body")
//@ApiImplicitParam(type = "query", name = "createBy",value = "创建者",required = true),
//@ApiImplicitParam(type = "query", name = "createTime",value = "创建时间",required = true)
})
@PostMapping("/register")
//@PreAuthorize("hasAuthority('ROLE_USER')")
public HttpResult register(String name, String password, Long deptId, String grade, String email, String mobile, @RequestParam List<Long> roleList, Mu ltipartFile uploadFile ) throws FileNotFoundException {
//MultipartFile uploadFile = null;
这个真的是折磨了我⼀下午,最后还是不能偷懒,只能放弃映射,⼀个个的写参数,最后在⽅法中新建bean
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论