自定义注解
package com.jianmu.bean.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- @author kong
- Retention RetentionPolicy.RUNTIME 运行时
- Target ElementType.FIELD 属性
*/
@Target({ElementType.FIELD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Grade {
String value() default "";
int number() default 0;
在属性上加注解
package com.jianmu.bean.member.act.config;
import com.alibaba.fastjson.JSONArray;
import com.jianmu.bean.annotation.Grade;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
- @author kong
*/
@Data
@Accessors(chain = true)
public class ActUpdateConfigAdParam {
@NotNull(message = "活动id不能为空")
private Long aid;
@ApiModelProperty("启用开屏")
@Grade("openScreenEnabled")
private Boolean openScreenEnabled;
@ApiModelProperty("开屏跳转方式 0 自动 1点击")
private Integer openScreenJumpMode;
@ApiModelProperty("开屏图片地址")
private String openScreen;
@Grade("voteAdEnabled")
@ApiModelProperty("启用投票广告")
private Boolean voteAdEnabled;
@ApiModelProperty("投票广告图片地址")
private String voteAd;
@ApiModelProperty("投票成功跳转地址")
private String voteAdJumpLink;
@Grade("bottomAdEnabled")
@ApiModelProperty("启用底部广告")
private Boolean bottomAdEnabled;
@ApiModelProperty("底部广告图地址")
private String bottomAd;
@ApiModelProperty("底部广告跳转地址")
private String bottomAdJumpLink;
@Grade("vtCarouselAdEnabled")
@ApiModelProperty("投票页轮播图广告启用")
private Boolean vtCarouselAdEnabled;
@Grade("dynamicCarouselAdEnabled")
@ApiModelProperty("动态页轮播图广告启用")
private Boolean dynamicCarouselAdEnabled;
@ApiModelProperty("轮播图广告数组")
private JSONArray carouselAd;
}
标签:段值,String,自定义,Grade,private,ApiModelProperty,import,注解,annotation
From: https://blog.51cto.com/u_16274468/8202181