Java Code Examples for org.mybatis.generator.api.IntrospectedColumn#getRemarks()

The following examples show how to use org.mybatis.generator.api.IntrospectedColumn#getRemarks() . 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: DG2CommentGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    // 添加字段注释
    StringBuffer sb = new StringBuffer();
    field.addJavaDocLine("/**");
    //对应表中字段的备注(数据库中自己写的备注信息)
    if (introspectedColumn.getRemarks() != null)
        field.addJavaDocLine(" * " + introspectedColumn.getRemarks());
    sb.append(" * 表字段 : ");
    //对应表名称
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    //对应表中字段的名称
    sb.append(introspectedColumn.getActualColumnName());
    field.addJavaDocLine(sb.toString());
    // addJavadocTag(field, false);
    field.addJavaDocLine(" */");
}
 
Example 3
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 4
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 5
Source File: DGCommentGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    // 添加字段注释
    StringBuffer sb = new StringBuffer();
    field.addJavaDocLine("/**");
    field.addJavaDocLine(" * <pre>");
    if (introspectedColumn.getRemarks() != null)
        field.addJavaDocLine(" * " + introspectedColumn.getRemarks());
    sb.append(" * 表字段 : ");
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    field.addJavaDocLine(sb.toString());
    field.addJavaDocLine(" * </pre>");
    // addJavadocTag(field, false);
    field.addJavaDocLine(" */");
}
 
Example 6
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 7
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 8
Source File: CommentGenerator.java    From mall-swarm 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 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 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 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: CommentGenerator.java    From macrozheng 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 13
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 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: 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 17
Source File: CommentGenerator.java    From zheng with MIT License 5 votes vote down vote up
@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
	super.addFieldComment(field, introspectedTable, introspectedColumn);
	if (introspectedColumn.getRemarks() != null && !"".equals(introspectedColumn.getRemarks())) {
		field.addJavaDocLine("/**");
		field.addJavaDocLine(" * " + introspectedColumn.getRemarks());
		addJavadocTag(field, false);
		field.addJavaDocLine(" */");
	}
}
 
Example 18
Source File: MyCommentGenerator.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
    if (suppressAllComments) {
        return;
    }

    //字段备注信息
    String remarks = introspectedColumn.getRemarks();
    field.addJavaDocLine("/**");
    field.addJavaDocLine(" * " + remarks);
    field.addJavaDocLine(" */");
    if (supportSwagger) {
        field.addJavaDocLine("@ApiModelProperty(value = \"" + remarks + "\")");
    }
}
 
Example 19
Source File: DefaultCommentGenerator.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public void addFieldComment(Field field,
        IntrospectedTable introspectedTable,
        IntrospectedColumn introspectedColumn) {
    if (suppressAllComments) {
        return;
    }

    field.addJavaDocLine("/**");

    String remarks = introspectedColumn.getRemarks();
    if (addRemarkComments && StringUtility.stringHasValue(remarks)) {
        field.addJavaDocLine(" * Database Column Remarks:");
        String[] remarkLines = remarks.split(System.getProperty("line.separator")); 
        for (String remarkLine : remarkLines) {
            field.addJavaDocLine(" *   " + remarkLine); 
        }
    }

    field.addJavaDocLine(" *");
    field
            .addJavaDocLine(" * This field was generated by MyBatis Generator.");

    StringBuilder sb = new StringBuilder();
    sb.append(" * This field corresponds to the database column ");
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    field.addJavaDocLine(sb.toString());

    addJavadocTag(field, false);

    field.addJavaDocLine(" */");
}
 
Example 20
Source File: MybatisEnumsPlugin.java    From java-master with Apache License 2.0 4 votes vote down vote up
@Override
public boolean modelFieldGenerated(Field field, TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn
        , IntrospectedTable introspectedTable, ModelClassType modelClassType) {
    String remark = introspectedColumn.getRemarks();
    if (!remark.contains(ENUM_FLAG)) {
        return super.modelFieldGenerated(field, topLevelClass, introspectedColumn, introspectedTable, modelClassType);
    }

    String enumClassName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1) + "Enum";
    String enumValue = remark.split("-")[1];
    String[] enums = enumValue.split(";");

    List<EnumMustacheField> list = Arrays.stream(enums)
            .map(s -> {
                String[] tmp = s.split(":");
                EnumMustacheField enumMustacheField = new EnumMustacheField();
                enumMustacheField.setLabel(tmp[0]);
                enumMustacheField.setCode(Integer.parseInt(tmp[1]));
                enumMustacheField.setMsg(tmp[2]);
                return enumMustacheField;
            })
            .collect(Collectors.toList());


    EnumMustacheBean enumMustacheBean = new EnumMustacheBean();
    enumMustacheBean.setEnumPath(enumPath);
    enumMustacheBean.setEnumClassName(enumClassName);
    enumMustacheBean.setEnumFields(list);

    DefaultShellCallback callback = new DefaultShellCallback(true);
    try {
        File directory = callback.getDirectory(targetProject, enumPath);
        File targetFile = new File(directory, enumClassName + ".java");
        Mustache mustache = mf.compile("template/Enum.mustache");
        mustache.execute(new PrintWriter(targetFile), enumMustacheBean).flush();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }


    return super.modelFieldGenerated(field, topLevelClass, introspectedColumn, introspectedTable, modelClassType);
}