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

The following examples show how to use org.mybatis.generator.internal.util.StringUtility. 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 File: CommentGenerator.java    From mall-learning with 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 #2
Source File: CommentGenerator.java    From mall with 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 #3
Source File: AnnotatedClientGenerator.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: CommentGenerator.java    From server with 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 #5
Source File: CommentGenerator.java    From HIS with 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 File: CommentGenerator.java    From HIS with 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 #7
Source File: IncrementPlugin.java    From mybatis-generator-plugin with 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 #8
Source File: EnumTypeStatusPlugin.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 解析注释
 * @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 #9
Source File: CommentGenerator.java    From HIS with 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 #10
Source File: CommentGenerator.java    From macrozheng-mall with 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 #11
Source File: DefaultCommentGenerator.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
@Override
public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable,
        IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) {
    imports.add(new FullyQualifiedJavaType("javax.annotation.Generated"));
    String comment = "Source field: "
            + introspectedTable.getFullyQualifiedTable().toString()
            + "."
            + introspectedColumn.getActualColumnName();
    field.addAnnotation(getGeneratedAnnotation(comment));
    
    if (!suppressAllComments && addRemarkComments) {
        String remarks = introspectedColumn.getRemarks();
        if (addRemarkComments && StringUtility.stringHasValue(remarks)) {
            field.addJavaDocLine("/**");
            field.addJavaDocLine(" * Database Column Remarks:");
            String[] remarkLines = remarks.split(System.getProperty("line.separator")); 
            for (String remarkLine : remarkLines) {
                field.addJavaDocLine(" *   " + remarkLine); 
            }
            field.addJavaDocLine(" */");
        }
    }
}
 
Example #12
Source File: LombokPlugin.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 具体执行顺序 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 findData = false;
    for (Object key : properties.keySet()) {
        String annotation = key.toString().trim();
        if (annotation.startsWith("@Data")) {
            findData = true;
        }

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

    if (!findData) {
        this.annotations.add(0, "@Data");
    }

    // 老版本IDEA SuperBuilder支持
    this.suportSuperBuilderForIdea = StringUtility.isTrue(properties.getProperty(PRO_SUPPORT_SUPER_BUILDER_FOR_IDEA));
}
 
Example #13
Source File: CommentGenerator.java    From HIS with 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 #14
Source File: CommentGenerator.java    From mall-learning with 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 #15
Source File: CommentGenerator.java    From mall-learning with 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 File: MapperPlugin.java    From tk-mybatis with MIT License 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 #17
Source File: CommentGenerator.java    From mall-learning with 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 File: GenCommentGenerator.java    From scaffold-cloud with 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(" */");
}
 
Example #19
Source File: CommentGenerator.java    From mall-learning with 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
Source File: CommentGenerator.java    From mall-learning with 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 #21
Source File: CommentGenerator.java    From mall-learning with 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 File: HySwaggerMapperPlugin.java    From jvue-admin with 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 #23
Source File: CommentGenerator.java    From mall-learning with 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 #24
Source File: IntrospectedTableTools.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 安全获取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 #25
Source File: TemplateCommentGenerator.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 添加评论
 * @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 #26
Source File: CommentGenerator.java    From mall-learning with 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 #27
Source File: MapperCommentGenerator.java    From tk-mybatis with 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 #28
Source File: CommentGenerator.java    From mall-learning with 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 #29
Source File: MapperCommentGenerator.java    From Mapper with 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 #30
Source File: SqlScriptRunner.java    From dolphin with 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;
}