某个controller中的接口添加swagger注解@ApiOperation后swagger界面失效
程序员文章站
2022-07-02 21:11:19
...
相关java代码
controller
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunchi.common.annotation.AbstractController;
import com.yunchi.common.annotation.Login;
import com.yunchi.common.annotation.LoginUser;
import com.yunchi.common.exception.RRException;
import com.yunchi.common.response.base.AppResponse;
import com.yunchi.common.response.enums.AppResponseCode;
import com.yunchi.common.utils.ToolUtil;
import com.yunchi.common.validator.ValidatorUtils;
import com.yunchi.modules.center.dto.LoginUserDTO;
import com.yunchi.modules.center.entity.SysApplyEntity;
import com.yunchi.modules.center.entity.SysSchoolInfoEntity;
import com.yunchi.modules.center.service.SysApplyService;
import com.yunchi.modules.center.service.SysSchoolInfoService;
import com.yunchi.modules.xxtz.entity.form.SendMessageForm;
import com.yunchi.modules.xxtz.entity.vo.MessageVo;
import com.yunchi.modules.xxtz.service.MessageRecordService;
import com.yunchi.modules.xxtz.service.MessageReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
* @author pengcb
* @email aaa@qq.com
* @date 2020-07-28 11:36:49
*/
@Api(tags = "消息通知模块")
@RestController
@RequestMapping("api/xxtz/messagerecord")
public class MessageRecordController extends AbstractController {
@Autowired
private MessageRecordService messageRecordService;
@Autowired
private MessageReplyService messageReplyService;
@Autowired
private SysSchoolInfoService sysSchoolInfoService;
@Autowired
private SysApplyService sysApplyService;
/**
* 通过dept_ids和userIds确认所有发送对象
*
* @param loginUserDTO
* @param form
* @return
*/
@Login
@PostMapping("/sendMessage")
@ApiOperation("会出问题。。。。。")
public AppResponse sendMessage(@ApiIgnore @LoginUser LoginUserDTO loginUserDTO,
@RequestBody SendMessageForm form) {
//多文件
List<MultipartFile> multipartFiles = form.getMultipartHttpServletRequest().getFiles("file");
form.setMultipartFiles(multipartFiles);
//校验数据
ValidatorUtils.validateEntity(form);
//学校zipcode
String schoolZipCode = loginUserDTO.getSchoolZipCode();
//获取corpId
SysSchoolInfoEntity schoolInfoEntity = sysSchoolInfoService.
getOne(new QueryWrapper<SysSchoolInfoEntity>()
.eq("zip_code", schoolZipCode));
if (ToolUtil.isEmpty(schoolInfoEntity)) {
throw new RRException("学校信息不存在");
}
String corpId = schoolInfoEntity.getCorpid();
//获取sys_apply表中的applyId
SysApplyEntity applyEntity = sysApplyService.getById(28);
if (ToolUtil.isEmpty(applyEntity)) {
throw new RRException("应用不存在,检查sys_apply!");
}
Integer applyId = applyEntity.getApplyId();
boolean send = messageRecordService.sendMessage(form, applyId, corpId, loginUserDTO);
if (send) {
return new AppResponse(AppResponseCode.CODE_SUCCESS);
}
return new AppResponse(AppResponseCode.STATUS_FAILED);
}
}
form
package com.yunchi.modules.xxtz.entity.form;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* @Author pengcb
* @email aaa@qq.com
* @date 2020/8/1 16:17
*/
@Data
@ApiModel(value = "老师发送消息入参")
public class SendMessageForm {
@NotBlank(message = "消息内容不能为空")
@ApiModelProperty(name = "message", value = "消息内容", example = "消息内容")
private String message;
@ApiModelProperty(name = "deptIds", value = "班级列表", example = "{\"9521067\",\"9521068\"}")
private List<String> deptIds;
@ApiModelProperty(name = "zipCodes", value = "部门zipCode", example = "{\"9521067\",\"9521068\"}")
private List<String> zipCodes;
@ApiModelProperty(name = "ids", value = "学生id列表", example = "{666679}")
private List<Long> ids;
@ApiModelProperty(name = "ids", value = "学生userId列表", example = "{\"d5c248f7caabbfbfa6fdd14396054bb2\"}")
private List<String> userIds;
@ApiModelProperty(name = "reply", value = "是否需要回复", example = "1")
private Integer reply;
@ApiModelProperty(name = "multipartFiles", value = "附件列表", hidden = true)
List<MultipartFile> multipartFiles;
@ApiModelProperty(name = "multipartFiles", value = "附件列表")
MultipartHttpServletRequest multipartHttpServletRequest;
}
问题待解决
sendMessage方法加了swagger注解后,swagger界面就不会显示接口列表,但是页面可以进去,网页报错如图:
。。。。。。。。。。。。。。。
解决办法
暂无