Java Code Examples for org.mybatis.generator.internal.util.StringUtility

The following examples show how to use org.mybatis.generator.internal.util.StringUtility. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: server   Source File: CommentGenerator.java    License: MIT License 6 votes vote down vote up
/**
 * 给字段添加注释
 */
@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                            IntrospectedColumn introspectedColumn) {
    String remarks = introspectedColumn.getRemarks();
    //根据参数和备注信息判断是否添加备注信息
    if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
        //文档注释开始
        field.addJavaDocLine("/**");
        //获取数据库字段的备注信息
        String[] remarkLines = remarks.split(System.getProperty("line.separator"));
        for(String remarkLine:remarkLines){
            field.addJavaDocLine(" * "+remarkLine);
        }
        addJavadocTag(field, false);
        field.addJavaDocLine(" */");
    }
}
 
Example 2
@Override
public List<CompilationUnit> getExtraCompilationUnits() {
    boolean useLegacyBuilder = false;

    String prop = context.getJavaClientGeneratorConfiguration()
            .getProperty(PropertyRegistry.CLIENT_USE_LEGACY_BUILDER);
    if (StringUtility.stringHasValue(prop)) {
        useLegacyBuilder = Boolean.valueOf(prop);
    }
    SqlProviderGenerator sqlProviderGenerator = new SqlProviderGenerator(getProject(), useLegacyBuilder);
    sqlProviderGenerator.setContext(context);
    sqlProviderGenerator.setIntrospectedTable(introspectedTable);
    sqlProviderGenerator.setProgressCallback(progressCallback);
    sqlProviderGenerator.setWarnings(warnings);
    return sqlProviderGenerator.getCompilationUnits();
}
 
Example 3
Source Project: HIS   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 4
Source Project: HIS   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 5
Source Project: HIS   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 6
Source Project: mybatis-generator-plugin   Source File: IncrementPlugin.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
 * @param introspectedTable
 */
@Override
public void initialized(IntrospectedTable introspectedTable) {
    super.initialized(introspectedTable);
    this.incColumns = new ArrayList<>();

    String incrementColumns = introspectedTable.getTableConfigurationProperty(PRO_INCREMENT_COLUMNS);
    if (StringUtility.stringHasValue(incrementColumns)) {
        // 切分
        String[] incrementsColumnsStrs = incrementColumns.split(",");
        for (String incrementsColumnsStr : incrementsColumnsStrs) {
            IntrospectedColumn column = IntrospectedTableTools.safeGetColumn(introspectedTable, incrementsColumnsStr);
            if (column == null) {
                warnings.add("itfsw:插件" + IncrementPlugin.class.getTypeName() + "插件没有找到column为" + incrementsColumnsStr.trim() + "的字段!");
            } else {
                incColumns.add(column);
            }
        }
    }
}
 
Example 7
Source Project: mall   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 8
Source Project: HIS   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 9
Source Project: macrozheng-mall   Source File: CommentGenerator.java    License: MIT License 6 votes vote down vote up
/**
 * 给字段添加注释
 */
@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                            IntrospectedColumn introspectedColumn) {
    String remarks = introspectedColumn.getRemarks();
    //根据参数和备注信息判断是否添加备注信息
    if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
        //文档注释开始
        field.addJavaDocLine("/**");
        //获取数据库字段的备注信息
        String[] remarkLines = remarks.split(System.getProperty("line.separator"));
        for(String remarkLine:remarkLines){
            field.addJavaDocLine(" * "+remarkLine);
        }
        addJavadocTag(field, false);
        field.addJavaDocLine(" */");
    }
}
 
Example 10
Source Project: HIS   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 11
Source Project: HIS   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 12
/**
 * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
 * @param introspectedTable
 * @return
 */
@Override
public void initialized(IntrospectedTable introspectedTable) {
    super.initialized(introspectedTable);

    this.annotations = new ArrayList<>();
    Properties properties = this.getProperties();
    boolean findMapper = false;
    for (Object key : properties.keySet()) {
        String annotation = key.toString().trim();
        if (annotation.startsWith("@Mapper")) {
            findMapper = true;
        }

        if (StringUtility.isTrue(properties.getProperty(key.toString()))) {
            this.annotations.add(annotation);
        }
    }

    if (!findMapper) {
        this.annotations.add(0, "@Mapper");
    }
}
 
Example 13
Source Project: azeroth   Source File: CrudSupportPlugin.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 处理实体类的包和@Table注解
 *
 * @param topLevelClass
 * @param introspectedTable
 */
private void processEntityClass(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    //引入JPA注解
    topLevelClass.addImportedType("javax.persistence.*");
    String tableName = introspectedTable.getFullyQualifiedTableNameAtRuntime();
    //如果包含空格,或者需要分隔符,需要完善
    if (StringUtility.stringContainsSpace(tableName)) {
        tableName = context.getBeginningDelimiter()
                + tableName
                + context.getEndingDelimiter();
    }
    //是否忽略大小写,对于区分大小写的数据库,会有用
    if (caseSensitive && !topLevelClass.getType().getShortName().equals(tableName)) {
        topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
    } else if (!topLevelClass.getType().getShortName().equalsIgnoreCase(tableName)) {
        topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
    } else if (StringUtility.stringHasValue(schema)
            || StringUtility.stringHasValue(beginningDelimiter)
            || StringUtility.stringHasValue(endingDelimiter)) {
        topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
    }
}
 
Example 14
/**
 * 解析注释
 * @param remarks
 */
public void parseRemarks(String remarks) throws CannotParseException {
    if (!StringUtility.stringHasValue(remarks) || !remarks.matches(REMARKS_PATTERN)) {
        throw new CannotParseException();
    } else {
        // 提取信息
        Pattern pattern = Pattern.compile(NEED_PATTERN);
        Matcher matcher = pattern.matcher(remarks);
        if (matcher.find() && matcher.groupCount() == 2) {
            String enumInfoStr = matcher.group(1);
            // 根据逗号切分
            String[] enumInfoStrs = enumInfoStr.split(",");

            // 提取每个节点信息
            for (String enumInfoItemStr : enumInfoStrs) {
                pattern = Pattern.compile(ITEM_PATTERN);
                matcher = pattern.matcher(enumInfoItemStr.trim());
                if (matcher.find() && matcher.groupCount() == 3) {
                    this.addItem(matcher.group(1), matcher.group(3), matcher.group(2));
                }
            }
        }
    }
}
 
Example 15
Source Project: HIS   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 16
Source Project: mall-learning   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 17
Source Project: mall-learning   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 18
Source Project: mall-learning   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 19
Source Project: mall-learning   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 20
/**
 * 添加评论
 * @param compilationUnit
 * @param map
 * @param node
 */
private void addCompilationUnitComment(CompilationUnit compilationUnit, Map<String, Object> map, EnumNode node) {
    if (this.suppressAllComments) {
        return;
    }
    // 获取评论
    String[] comments = getComments(map, node);
    if (comments != null) {
        // 去除空评论
        if (comments.length == 1 && !StringUtility.stringHasValue(comments[0])) {
            return;
        }
        // 添加评论
        for (String comment : comments) {
            compilationUnit.addFileCommentLine(comment);
        }
    }
}
 
Example 21
Source Project: mall-learning   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 22
Source Project: tk-mybatis   Source File: MapperCommentGenerator.java    License: MIT License 6 votes vote down vote up
/**
 * setter方法注释
 *
 * @param method
 * @param introspectedTable
 * @param introspectedColumn
 */
public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    StringBuilder sb = new StringBuilder();
    method.addJavaDocLine("/**");
    if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
        sb.append(" * 设置");
        sb.append(introspectedColumn.getRemarks());
        method.addJavaDocLine(sb.toString());
        method.addJavaDocLine(" *");
    }
    Parameter parm = method.getParameters().get(0);
    sb.setLength(0);
    sb.append(" * @param ");
    sb.append(parm.getName());
    if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
        sb.append(" ");
        sb.append(introspectedColumn.getRemarks());
    }
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" */");
}
 
Example 23
Source Project: Mapper   Source File: MapperCommentGenerator.java    License: MIT License 6 votes vote down vote up
/**
 * setter方法注释
 *
 * @param method
 * @param introspectedTable
 * @param introspectedColumn
 */
@Override
public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    StringBuilder sb = new StringBuilder();
    method.addJavaDocLine("/**");
    if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
        sb.append(" * 设置");
        sb.append(introspectedColumn.getRemarks());
        method.addJavaDocLine(sb.toString());
        method.addJavaDocLine(" *");
    }
    Parameter parm = method.getParameters().get(0);
    sb.setLength(0);
    sb.append(" * @param ");
    sb.append(parm.getName());
    if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
        sb.append(" ");
        sb.append(introspectedColumn.getRemarks());
    }
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" */");
}
 
Example 24
Source Project: dolphin   Source File: SqlScriptRunner.java    License: Apache License 2.0 6 votes vote down vote up
public SqlScriptRunner(String sourceFile, String driver, String url,
        String userId, String password) throws MojoExecutionException {
    
    if (!StringUtility.stringHasValue(sourceFile)) {
        throw new MojoExecutionException("SQL script file is required");
    }
    
    if (!StringUtility.stringHasValue(driver)) {
        throw new MojoExecutionException("JDBC Driver is required");
    }
    
    if (!StringUtility.stringHasValue(url)) {
        throw new MojoExecutionException("JDBC URL is required");
    }
    
    this.sourceFile = sourceFile;
    this.driver = driver;
    this.url = url;
    this.userid = userId;
    this.password = password;
}
 
Example 25
Source Project: mall-learning   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 26
/**
 * 安全获取column 通过正则获取的name可能包含beginningDelimiter&&endingDelimiter
 * @param introspectedTable
 * @param columnName
 * @return
 */
public static IntrospectedColumn safeGetColumn(IntrospectedTable introspectedTable, String columnName) {
    // columnName
    columnName = columnName.trim();
    // 过滤
    String beginningDelimiter = introspectedTable.getContext().getBeginningDelimiter();
    if (StringUtility.stringHasValue(beginningDelimiter)) {
        columnName = columnName.replaceFirst("^" + beginningDelimiter, "");
    }
    String endingDelimiter = introspectedTable.getContext().getEndingDelimiter();
    if (StringUtility.stringHasValue(endingDelimiter)) {
        columnName = columnName.replaceFirst(endingDelimiter + "$", "");
    }

    return introspectedTable.getColumn(columnName);
}
 
Example 27
Source Project: mall-learning   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 28
Source Project: jvue-admin   Source File: HySwaggerMapperPlugin.java    License: MIT License 6 votes vote down vote up
public void setProperties(Properties properties) {
	super.setProperties(properties);
	String sImplementSerializableInteface = this.properties.getProperty("implementSerializableInteface");
	if (StringUtility.stringHasValue(sImplementSerializableInteface)) {
		this.implementSerializableInteface = Boolean.parseBoolean(sImplementSerializableInteface);
	}

	String sModelFieldEnum = this.properties.getProperty("modelFieldEnum");
	if (StringUtility.stringHasValue(sModelFieldEnum)) {
		this.modelFieldEnum = Boolean.parseBoolean(sModelFieldEnum);
	}
	String swaggerApiEnabled = this.properties.getProperty("swaggerApiEnabled");
	if (StringUtility.stringHasValue(swaggerApiEnabled))
		this.swaggerApiEnabled = Boolean.parseBoolean(swaggerApiEnabled);
	
	String columnTypeEnabled = this.properties.getProperty("columnTypeEnabled");
	if (StringUtility.stringHasValue(columnTypeEnabled))
		this.columnTypeEnabled = Boolean.parseBoolean(columnTypeEnabled);
}
 
Example 29
Source Project: mall-learning   Source File: CommentGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加备注信息
        if(addRemarkComments&&StringUtility.stringHasValue(remarks)){
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if(remarks.contains("\"")){
                remarks = remarks.replace("\"","'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \""+remarks+"\")");
        }
    }
 
Example 30
Source Project: scaffold-cloud   Source File: GenCommentGenerator.java    License: MIT License 6 votes vote down vote up
/**
 * getter方法注释
 * @param method
 * @param introspectedTable
 * @param introspectedColumn
 */
@Override
public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
	StringBuilder sb = new StringBuilder();
	method.addJavaDocLine("/**");
	if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
		sb.append(" * 获取");
		sb.append(introspectedColumn.getRemarks());
		method.addJavaDocLine(sb.toString());
		method.addJavaDocLine(" *");
	}
	sb.setLength(0);
	sb.append(" * @return ");
	sb.append(introspectedColumn.getActualColumnName());
	if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
		sb.append(" - ");
		sb.append(introspectedColumn.getRemarks());
	}
	method.addJavaDocLine(sb.toString());
	method.addJavaDocLine(" */");
}