swagger2 注解使用

@RestController
@RequestMapping("/applet/message")
@Api(value = "小程序消息推送接口", tags = {"小程序消息推送接口"})
public class AppletSendMessageConrtoller {

    @Autowired
    private WxMaProperties wxMaProperties;

    @Autowired
    private AppletSendMessageService appletSendMessageService;

    @GetMapping("/getTemplateList")
    @LogAspect
    @ApiOperation(value = "获取模板信息(后台使用)", notes = "获取模板信息(后台使用)", httpMethod = "GET")
    public R getTemplateList() throws WxErrorException {
        return appletSendMessageService.getTemplateList();
    }


    @GetMapping("/getTemIdByBusiness")
    @ApiOperation(value = "根据业务场景获取模板id", notes = "根据业务场景获取模板id", httpMethod = "GET")
    @ApiImplicitParam(name = "businessNodeList", value = "业务场景编号集合",paramType = "query",dataType = "String",allowMultiple = true)
    @LogAspect
    public R getTemIdByBusiness(@RequestParam("businessNodeList") String[] businessNodeList) {
        return appletSendMessageService.getTemIdByBusiness(businessNodeList);
    }


    @PostMapping("/send")
    @ApiOperation(value = "消息推送接口", notes = "消息推送接口", httpMethod = "POST")
    @ApiImplicitParam(name = "activityTemplateSendVo", value = "消息实体vo",paramType = "body",dataType = "ActivityTemplateSendVo")
    @LogAspect
    public R sendWxMessage(@RequestBody ActivityTemplateSendVo activityTemplateSendVo) {
        return appletSendMessageService.sendWxActivityMessage(activityTemplateSendVo);
    }


    @PostMapping("/subscrip/permit/{touser}")
    @ApiOperation(value = "记录用户订阅信息是否授权接口", notes = "记录用户订阅信息是否授权接口", httpMethod = "POST")
    @ApiImplicitParams({@ApiImplicitParam(name = "touser", value = "用户openId" , paramType = "path",dataType = "String"),
            @ApiImplicitParam(name = "permitResult", value = "业务场景授权键值",  paramType = "body",allowMultiple = true, dataType = "SubScripData"),
    })
    public R subscripPermitInfo(@PathVariable("touser") String touser, @RequestBody ArrayList<SubScripData> permitResult) {
        return appletSendMessageService.subscripPermitInfo(touser, permitResult);
    }

    @PostMapping("/compensateMessage")
    @ApiOperation(value = "小程序订阅消息补偿接口", notes = "小程序订阅消息补偿接口", httpMethod = "POST")
    @ApiImplicitParams({@ApiImplicitParam(name = "touser",value = "用户openId"),
            @ApiImplicitParam(name = "activityId", value = "活动id",paramType = "String",dataType = "String"),
            @ApiImplicitParam(name = "businessNode", value = "业务场景节点编号",paramType = "String",dataType = "String"),
    })
    public R compensateMessage(String touser, String activityId, String businessNode) {
        return appletSendMessageService.compensateMessage(touser, activityId, businessNode);
    }
}

@ApiImplicitParam 注解属性:

  • name : 请求中的参数。
  • value : 参数的中文解释。
  • paramType :传参类型(位置),可选 query,body,path,header,form。对应@requestParam,@RequestBody,@PathVariable,@requestHeader等。
  • dataType :参数类型,可选基本数据类型和引用数据类型,如String,int,也可以选择自定义对象类型,如UserDto。
  • allowMultiple : 是否可以传多个参数,如果为true,则表示参数为数组或集合。
@Data
@ApiModel(value = "消息发送实体对象")
public class ActivityTemplateSendVo {

    //openId
    private String touser;

    //业务节点
    private String businessNode;

    private String activityId;

    //中奖日期
    private Date lotteryTime;

    //奖品名称
    private String awardName;

    //发货物品名称
    private String goodsName;

    //发货单号
    @JsonIgnore
    private String expressNumber;

    //收货地址
    @ApiModelProperty(value = "收获地址",required = false,hidden = true)
    private String receiveAddress;

    //签到时间
    private Date registerTime;

}

@ApiModelProperty 注解属性

  • value: 字段名。
  • required :是否必传参数。
  • hidden:是否隐藏。

当对象参数中的个别字段不想在swagger ui中展示出来时,可以适用@JsonIgnore或者 @ApiModelProperty(value = “收获地址”,required = false,hidden = true),注意如果使用前者,则在对象序列化时该字段不会显示,即返回给前端的对象中不会显示这个字段。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值