某个controller中的接口添加swagger注解@ApiOperation后swagger界面失效

相关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 646047990@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 646047990@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界面就不会显示接口列表,但是页面可以进去,网页报错如图:

swagger界面失效
报错界面

。。。。。。。。。。。。。。。

解决办法

暂无

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值