com.baomidou.mybatisplus.annotation.FieldStrategy Java Examples

The following examples show how to use com.baomidou.mybatisplus.annotation.FieldStrategy. 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: summerframework   Author: spring-avengers   File: UpdateBatchById.java    License: Apache License 2.0 5 votes vote down vote up
protected String convertIfTag(SqlCommandType sqlCommandType, TableFieldInfo fieldInfo, String prefix,
    boolean colse) {
    /* 前缀处理 */
    String property = fieldInfo.getProperty();
    if (null != prefix) {
        property = prefix + property;
    }
    /* 判断策略 */
    if (sqlCommandType == SqlCommandType.INSERT && fieldInfo.getFieldStrategy() == FieldStrategy.DEFAULT) {
        return "";
    }
    if (fieldInfo.getFieldStrategy() == FieldStrategy.IGNORED) {
        return "";
    } else if (fieldInfo.getFieldStrategy() == FieldStrategy.NOT_EMPTY) {
        if (colse) {
            return "</if>";
        } else {
            return String.format("\n\t<if test=\"%s!=null and %s!=''\">", property, property);
        }
    } else {
        // FieldStrategy.NOT_NULL
        if (colse) {
            return "</if>";
        } else {
            return String.format("\n\t<if test=\"%s!=null\">", property);
        }
    }
}