Skip to content

字段长度展示问题解决方案 #67

@onepiecefyf

Description

@onepiecefyf

1、属性实体增加两个字段maximum,maxSize
public class ModelAttr implements Serializable {

private static final long serialVersionUID = -4074067438450613643L;

/** 属性名 **/
private String name = StringUtils.EMPTY;

/** 属性描述 **/
private String description;

/** 类型 **/
private String type = StringUtils.EMPTY;

/** 是否必填 **/
private String require = "否";

/** String类型最大长度 **/
private String maxLength = "";

/** Integer类型最大长度 **/
private String maximum = "";

/** 页面展示类型最大长度 **/
private String maxSize = "-";

/** 约束与说明 **/
private String remark = "";

/** 入参深度 */
private int requestDep;

/**
 * 嵌套属性列表
 */
private List<ModelAttr> properties = new ArrayList<>();

/**
 * 是否加载完成,避免循环引用
 */
private boolean isCompleted = false;

}

2、方法cn.org.bjca.swagger.word.service.impl.WordServiceImpl#getModelAttrs需要添加针对处理长度的逻辑
Object maximum = attrInfoMap.get("maximum");
Object maxLength = attrInfoMap.get("maxLength");
if (!Objects.isNull(maximum) && maximum.toString().length() < 5) {
child.setMaximum(maximum != null ? maximum.toString() : "");
}
if (!Objects.isNull(maxLength) && maxLength.toString().length() < 5) {
child.setMaxLength(maxLength != null ? maxLength.toString() : "");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions