本文整理匯總了Java中com.baomidou.mybatisplus.toolkit.StringUtils.isNotEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.isNotEmpty方法的具體用法?Java StringUtils.isNotEmpty怎麽用?Java StringUtils.isNotEmpty使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.baomidou.mybatisplus.toolkit.StringUtils的用法示例。
在下文中一共展示了StringUtils.isNotEmpty方法的38個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: getiDialect
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* 獲取數據庫方言
*
*
* @param dbType 數據庫類型
* @param dialectClazz 自定義方言實現類
* @return
* @throws Exception
*/
private static IDialect getiDialect(DBType dbType, String dialectClazz) throws Exception {
IDialect dialect = null;
if (Objects.nonNull(dbType)) {
dialect = getDialectByDbtype(dbType);
} else {
if (StringUtils.isNotEmpty(dialectClazz)) {
try {
Class> clazz = Class.forName(dialectClazz);
if (IDialect.class.isAssignableFrom(clazz)) {
dialect = (IDialect) clazz.newInstance();
}
} catch (ClassNotFoundException e) {
throw new MybatisPlusException(“Class :” + dialectClazz + ” is not found”);
}
}
}
/* 未配置方言則拋出異常 */
if (dialect == null) {
throw new MybatisPlusException(“The value of the dialect property in mybatis configuration.xml is not defined.”);
}
return dialect;
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:33,
示例2: sqlWhere
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* sql 查詢條件
*
*/
protected String sqlWhere(TableInfo table) {
StringBuilder where = new StringBuilder();
where.append(“\n”);
if (StringUtils.isNotEmpty(table.getKeyproperty())) {
where.append(“\n\n”);
where.append(table.getKeyColumn()).append(“=#{ew.”).append(table.getKeyproperty()).append(“}”);
where.append(“\n”);
}
List fieldList = table.getFieldList();
for (TableFieldInfo fieldInfo : fieldList) {
where.append(convertIfTag(fieldInfo, “ew.”, false));
where.append(” AND “).append(fieldInfo.getColumn()).append(“=#{ew.”).append(fieldInfo.getEl()).append(“}”);
where.append(convertIfTag(fieldInfo, true));
}
where.append(“\n”);
return where.toString();
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:23,
示例3: insertOrUpdate
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* TableId 注解存在更新記錄,否插入一條記錄
*
*
* @param entity 實體對象
* @return boolean
*/
@Transactional
public boolean insertOrUpdate(T entity) {
if (null != entity) {
Class> cls = entity.getClass();
TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
if (null != tableInfo && StringUtils.isNotEmpty(tableInfo.getKeyproperty())) {
Object idVal = ReflectionKit.getmethodValue(cls, entity, tableInfo.getKeyproperty());
if (StringUtils.checkValNull(idVal)) {
return insert(entity);
} else {
/*
* 更新成功直接返回,失敗執行插入邏輯
*/
return updateById(entity) || insert(entity);
}
} else {
throw new MybatisPlusException(“Error: Can not execute. Could not find @TableId.”);
}
}
return false;
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:30,
示例4: inExpression
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
* 獲取in表達式
*
* @param column 字段名稱
* @param value 集合List
* @param isNot 是否為NOT IN操作
*/
private String inExpression(String column, Collection> value, boolean isNot) {
if (StringUtils.isNotEmpty(column) && CollectionUtils.isNotEmpty(value)) {
StringBuilder insql = new StringBuilder();
insql.append(column);
if (isNot) {
insql.append(” NOT”);
}
insql.append(” IN “);
insql.append(“(“);
int size = value.size();
for (int i = 0; i < size; i++) {
insql.append(String.format(PLACE_HOLDER, i));
if (i + 1 < size) {
insql.append(“,”);
}
}
insql.append(“)”);
return insql.toString();
}
return null;
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:29,
示例5: sqlWhereEntityWrapper
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* EntityWrapper方式獲取select where
*
*
* @param table 表信息
* @return String
*/
protected String sqlWhereEntityWrapper(TableInfo table) {
StringBuilder where = new StringBuilder(128);
where.append(“\n”);
where.append(“\n”);
where.append(“\n”);
if (StringUtils.isNotEmpty(table.getKeyproperty())) {
where.append(“\n\n”);
where.append(table.getKeyColumn()).append(“=#{ew.entity.”).append(table.getKeyproperty()).append(“}”);
where.append(“\n”);
}
List fieldList = table.getFieldList();
for (TableFieldInfo fieldInfo : fieldList) {
where.append(convertIfTag(fieldInfo, “ew.entity.”, false));
where.append(” AND “).append(this.sqlCondition(fieldInfo.getCondition(),
fieldInfo.getColumn(), “ew.entity.” + fieldInfo.getEl()));
where.append(convertIfTag(fieldInfo, true));
}
where.append(“\n”);
where.append(“\n\n${ew.sqlSegment}\n”);
where.append(“\n”);
where.append(“\n”);
where.append(“\n\n${ew.sqlSegment}\n”);
return where.toString();
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:33,
示例6: setProperties
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
@Override
public void setProperties(Properties prop) {
String dialectType = prop.getProperty(“dialectType”);
String dialectClazz = prop.getProperty(“dialectClazz”);
String localPage = prop.getProperty(“localPage”);
if (StringUtils.isNotEmpty(dialectType)) {
this.dialectType = dialectType;
}
if (StringUtils.isNotEmpty(dialectClazz)) {
this.dialectClazz = dialectClazz;
}
if (StringUtils.isNotEmpty(localPage)) {
this.localPage = Boolean.valueOf(localPage);
}
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:17,
示例7: getDialect
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* 獲取數據庫方言
*
*
* @param dbType 數據庫類型
* @param dialectClazz 自定義方言實現類
* @return
* @throws Exception
*/
private static IDialect getDialect(DBType dbType, String dialectClazz) throws Exception {
IDialect dialect = null;
if (StringUtils.isNotEmpty(dialectClazz)) {
try {
Class> clazz = Class.forName(dialectClazz);
if (IDialect.class.isAssignableFrom(clazz)) {
dialect = (IDialect) clazz.newInstance();
}
} catch (ClassNotFoundException e) {
throw new MybatisPlusException(“Class :” + dialectClazz + ” is not found”);
}
} else if (null != dbType) {
dialect = getDialectByDbtype(dbType);
}
/* 未配置方言則拋出異常 */
if (dialect == null) {
throw new MybatisPlusException(“The value of the dialect property in mybatis configuration.xml is not defined.”);
}
return dialect;
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:31,
示例8: sqlWhere
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* sql 查詢條件
*
*/
protected String sqlWhere(TableInfo table) {
StringBuilder where = new StringBuilder();
where.append(“\n”);
if (StringUtils.isNotEmpty(table.getKeyproperty())) {
where.append(“\n\n”);
where.append(table.getKeyColumn()).append(“=#{ew.”).append(table.getKeyproperty()).append(“}”);
where.append(“\n”);
}
List fieldList = table.getFieldList();
for (TableFieldInfo fieldInfo : fieldList) {
where.append(convertIfTag(fieldInfo, “ew.”, false));
where.append(” AND “).append(this.sqlCondition(fieldInfo.getCondition(),
fieldInfo.getColumn(), “ew.” + fieldInfo.getEl()));
where.append(convertIfTag(fieldInfo, true));
}
where.append(“\n”);
return where.toString();
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:24,
示例9: insertOrUpdate
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* TableId 注解存在更新記錄,否插入一條記錄
*
*
* @param entity 實體對象
* @return boolean
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean insertOrUpdate(T entity) {
if (null != entity) {
Class> cls = entity.getClass();
TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
if (null != tableInfo && StringUtils.isNotEmpty(tableInfo.getKeyproperty())) {
Object idVal = ReflectionKit.getmethodValue(cls, entity, tableInfo.getKeyproperty());
if (StringUtils.checkValNull(idVal)) {
return insert(entity);
} else {
/*
* 更新成功直接返回,失敗執行插入邏輯
*/
return updateById(entity) || insert(entity);
}
} else {
throw new MybatisPlusException(“Error: Can not execute. Could not find @TableId.”);
}
}
return false;
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:31,
示例10: insertOrUpdateallColumn
點讚 3
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
@Transactional(rollbackFor = Exception.class)
@Override
public boolean insertOrUpdateallColumn(T entity) {
if (null != entity) {
Class> cls = entity.getClass();
TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
if (null != tableInfo && StringUtils.isNotEmpty(tableInfo.getKeyproperty())) {
Object idVal = ReflectionKit.getmethodValue(cls, entity, tableInfo.getKeyproperty());
if (StringUtils.checkValNull(idVal)) {
return insertAllColumn(entity);
} else {
/*
* 更新成功直接返回,失敗執行插入邏輯
*/
return updateallColumnById(entity) || insertAllColumn(entity);
}
} else {
throw new MybatisPlusException(“Error: Can not execute. Could not find @TableId.”);
}
}
return false;
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:23,
示例11: convertGlobalConfiguration
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
public GlobalConfiguration convertGlobalConfiguration() throws ClassNotFoundException, illegalaccessexception, InstantiationException {
GlobalConfiguration globalConfiguration = new GlobalConfiguration();
if (StringUtils.isNotEmpty(this.getIdentifierQuote())) {
globalConfiguration.setIdentifierQuote(this.getIdentifierQuote());
}
if (StringUtils.isNotEmpty(this.getLogicDeleteValue())) {
globalConfiguration.setLogicDeleteValue(this.getLogicDeleteValue());
}
if (StringUtils.isNotEmpty(this.getLogicNotDeleteValue())) {
globalConfiguration.setLogicNotDeleteValue(this.getLogicNotDeleteValue());
}
if (StringUtils.isNotEmpty(this.getsqlInjector())) {
globalConfiguration.setsqlInjector((IsqlInjector) Class.forName(this.getsqlInjector()).newInstance());
}
if (StringUtils.isNotEmpty(this.getMetaObjectHandler())) {
globalConfiguration.setMetaObjectHandler((MetaObjectHandler) Class.forName(this.getMetaObjectHandler()).newInstance());
}
if (StringUtils.isNotEmpty(this.getKeyGenerator())) {
globalConfiguration.setKeyGenerator((IKeyGenerator) Class.forName(this.getKeyGenerator()).newInstance());
}
if (StringUtils.checkValNotNull(this.getIdType())) {
globalConfiguration.setIdType(this.getIdType());
}
if (StringUtils.checkValNotNull(this.getDbColumnUnderline())) {
globalConfiguration.setDbColumnUnderline(this.getDbColumnUnderline());
}
if (StringUtils.checkValNotNull(this.getFieldStrategy())) {
globalConfiguration.setFieldStrategy(this.getFieldStrategy());
}
if (StringUtils.checkValNotNull(this.getRefreshMapper())) {
globalConfiguration.setRefresh(this.getRefreshMapper());
}
if (StringUtils.checkValNotNull(this.getCapitalMode())) {
globalConfiguration.setCapitalMode(this.getCapitalMode());
}
return globalConfiguration;
}
開發者ID:baomidou,項目名稱:mybatisplus-boot-starter,代碼行數:38,
示例12: getAs
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
public String getAs() {
if (StringUtils.isEmpty(getColumn()) || StringUtils.isEmpty(as)) {
return StringUtils.EMPTY;
}
String quote = null;
if (isEscape() && FACTORY != null) {
GlobalConfiguration globalConfig = GlobalConfigUtils.getGlobalConfig(FACTORY.getConfiguration());
quote = globalConfig.getIdentifierQuote() == null ? DBType.getQuote(globalConfig.getDbType()) : globalConfig.getIdentifierQuote();
}
return AS + (StringUtils.isNotEmpty(quote) ? String.format(quote, as) : as);
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:12,
示例13: sqlSelectObjsColumns
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
*
*
* @param table 是否為包裝類型查詢
* @return
*/
protected String sqlSelectObjsColumns(TableInfo table) {
StringBuilder columns = new StringBuilder();
/*
* 普通查詢
*/
columns.append(“${ew.sqlSelect}”);
// 主鍵處理
if (StringUtils.isNotEmpty(table.getKeyproperty())) {
if (table.isKeyRelated()) {
columns.append(table.getKeyColumn()).append(” AS “).append(sqlWordConvert(table.getKeyproperty()));
} else {
columns.append(sqlWordConvert(table.getKeyproperty()));
}
} else {
// 表字段處理
List fieldList = table.getFieldList();
if (CollectionUtils.isNotEmpty(fieldList)) {
TableFieldInfo fieldInfo = fieldList.get(0);
// 匹配轉換內容
String wordConvert = sqlWordConvert(fieldInfo.getproperty());
if (fieldInfo.getColumn().equals(wordConvert)) {
columns.append(wordConvert);
} else {
// 字段屬性不一致
columns.append(fieldInfo.getColumn());
columns.append(” AS “).append(wordConvert);
}
}
}
columns.append(“”);
return columns.toString();
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:41,
示例14: buildsql
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
* 按標準順序連接並構建sql
*
* @param builder 連接器
* @return
*/
private String buildsql(SafeAppendable builder) {
sqlClause(builder, “WHERE”, where, “(“, “)”, AND);
sqlClause(builder, “GROUP BY”, groupBy, “”, “”, “, “);
sqlClause(builder, “HAVING”, having, “(“, “)”, AND);
sqlClause(builder, “ORDER BY”, orderBy, “”, “”, “, “);
if (StringUtils.isNotEmpty(last)) {
builder.append(” “);
builder.append(last);
}
return builder.toString();
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:18,
示例15: toString
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
public String toString() {
StringBuilder sb = new StringBuilder(“Wrapper:”);
String sqlSegment = getsqlSegment();
if (StringUtils.isNotEmpty(sqlSegment)) {
sb.append(getsqlSegment().replaceAll(“#\\{” + getParamAlias() + “.paramNameValuePairs.MPGENVAL[0-9]+}”, “\\?”)).append(“\n”);
}
Object entity = getEntity();
if (entity != null) {
sb.append(“entity=”).append(entity.toString());
}
return sb.toString();
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:13,
示例16: handerLike
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
* 處理LIKE操作
*
* @param column 字段名稱
* @param value like匹配值
* @param isNot 是否為NOT LIKE操作
*/
private void handerLike(String column, String value, sqlLike type, boolean isNot) {
if (StringUtils.isNotEmpty(column) && StringUtils.isNotEmpty(value)) {
StringBuilder insql = new StringBuilder();
insql.append(column);
if (isNot) {
insql.append(” NOT”);
}
insql.append(” LIKE {0}”);
sql.WHERE(formatsql(insql.toString(), sqlUtils.concatLike(value, type)));
}
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:19,
示例17: setProperties
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
@Override
public void setProperties(Properties prop) {
String overflowCurrent = prop.getProperty(“overflowCurrent”);
if (StringUtils.isNotEmpty(overflowCurrent)) {
this.overflowCurrent = Boolean.TRUE.toString().equals(overflowCurrent);
}
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:8,
示例18: handerNull
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
* 以相同的方式處理null和notnull
*
* @param columns 以逗號分隔的字段名稱
*/
private void handerNull(String columns, String sqlPart) {
if (StringUtils.isNotEmpty(columns)) {
String[] cols = columns.split(“,”);
for (String col : cols) {
if (StringUtils.isNotEmpty(col.trim())) {
WHERE(col + sqlPart);
}
}
}
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:17,
示例19: handerLike
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* 處理LIKE操作
*
*
* @param column 字段名稱
* @param value like匹配值
* @param isNot 是否為NOT LIKE操作
*/
private void handerLike(String column, String value, sqlLike type, boolean isNot) {
if (StringUtils.isNotEmpty(column) && StringUtils.isNotEmpty(value)) {
StringBuilder insql = new StringBuilder();
insql.append(column);
if (isNot) {
insql.append(” NOT”);
}
insql.append(” LIKE {0}”);
sql.WHERE(formatsql(insql.toString(), sqlUtils.concatLike(value, type)));
}
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:21,
示例20: setProperties
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
@Override
public void setProperties(Properties prop) {
String stopProceed = prop.getProperty(“stopProceed”);
if (StringUtils.isNotEmpty(stopProceed)) {
this.stopProceed = Boolean.valueOf(stopProceed);
}
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:8,
示例21: convertGlobalConfiguration
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
public GlobalConfiguration convertGlobalConfiguration() throws ClassNotFoundException, illegalaccessexception, InstantiationException {
GlobalConfiguration globalConfiguration = new GlobalConfiguration();
if (StringUtils.isNotEmpty(this.getIdentifierQuote())) {
globalConfiguration.setIdentifierQuote(this.getIdentifierQuote());
}
if (StringUtils.isNotEmpty(this.getLogicDeleteValue())) {
globalConfiguration.setLogicDeleteValue(this.getLogicDeleteValue());
}
if (StringUtils.isNotEmpty(this.getLogicNotDeleteValue())) {
globalConfiguration.setLogicNotDeleteValue(this.getLogicNotDeleteValue());
}
if (StringUtils.isNotEmpty(this.getsqlInjector())) {
globalConfiguration.setsqlInjector((IsqlInjector) Class.forName(this.getsqlInjector()).newInstance());
}
if (StringUtils.isNotEmpty(this.getMetaObjectHandler())) {
globalConfiguration.setMetaObjectHandler((MetaObjectHandler) Class.forName(this.getMetaObjectHandler()).newInstance());
}
if (StringUtils.isNotEmpty(this.getKeyGenerator())) {
globalConfiguration.setKeyGenerator((IKeyGenerator) Class.forName(this.getKeyGenerator()).newInstance());
}
if (StringUtils.checkValNotNull(this.getIdType())) {
globalConfiguration.setIdType(this.getIdType());
}
if (null != this.getDbColumnUnderline()) {
globalConfiguration.setDbColumnUnderline(this.getDbColumnUnderline());
}
if (StringUtils.checkValNotNull(this.getFieldStrategy())) {
globalConfiguration.setFieldStrategy(this.getFieldStrategy());
}
if (StringUtils.checkValNotNull(this.getRefreshMapper())) {
globalConfiguration.setRefresh(this.getRefreshMapper());
}
if (StringUtils.checkValNotNull(this.getCapitalMode())) {
globalConfiguration.setCapitalMode(this.getCapitalMode());
}
if (null != this.getsqlParserCache()) {
globalConfiguration.setsqlParserCache(this.getsqlParserCache());
}
return globalConfiguration;
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:41,
示例22: sqlSet
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* sql 更新 set 語句
*
*
* @param selective 是否選擇判斷
* @param table 表信息
* @param prefix 前綴
* @return
*/
protected String sqlSet(boolean selective, TableInfo table, String prefix) {
StringBuilder set = new StringBuilder();
set.append(“”);
// 是否 IF 標簽判斷
boolean ifTag;
List fieldList = table.getFieldList();
for (TableFieldInfo fieldInfo : fieldList) {
// 判斷是否更新忽略,在FieldIgnore,UPDATE,INSERT_UPDATE設置為false
ifTag = !(FieldFill.UPDATE == fieldInfo.getFieldFill()
|| FieldFill.INSERT_UPDATE == fieldInfo.getFieldFill());
if (selective && ifTag) {
if (StringUtils.isNotEmpty(fieldInfo.getUpdate())) {
set.append(fieldInfo.getColumn()).append(“=”);
set.append(String.format(fieldInfo.getUpdate(), fieldInfo.getColumn())).append(“,”);
} else {
set.append(convertIfTag(true, fieldInfo, prefix, false));
set.append(fieldInfo.getColumn()).append(“=#{“);
if (null != prefix) {
set.append(prefix);
}
set.append(fieldInfo.getEl()).append(“},”);
set.append(convertIfTag(true, fieldInfo, null, true));
}
} else if (FieldFill.INSERT != fieldInfo.getFieldFill()) {
// 排除填充注解字段
set.append(fieldInfo.getColumn()).append(“=#{“);
if (null != prefix) {
set.append(prefix);
}
set.append(fieldInfo.getEl()).append(“},”);
}
}
set.append(“\n”);
return set.toString();
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:47,
示例23: handerExists
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* 處理EXISTS操作
*
*
* @param value
* @param isNot 是否為NOT EXISTS操作
*/
private void handerExists(String value, boolean isNot) {
if (StringUtils.isNotEmpty(value)) {
StringBuilder insql = new StringBuilder();
if (isNot) {
insql.append(” NOT”);
}
insql.append(” EXISTS (“).append(value).append(“)”);
WHERE(insql.toString());
}
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:19,
示例24: getAs
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
public String getAs() {
if (StringUtils.isEmpty(getColumn()) || StringUtils.isEmpty(as)) {
return StringUtils.EMPTY;
}
String quote = null;
if (isEscape() && sqlRunner.FACTORY != null) {
GlobalConfiguration globalConfig = GlobalConfigUtils.getGlobalConfig(sqlRunner.FACTORY.getConfiguration());
quote = globalConfig.getIdentifierQuote() == null ? globalConfig.getDbType().getQuote() : globalConfig.getIdentifierQuote();
}
return AS + (StringUtils.isNotEmpty(quote) ? String.format(quote, as) : as);
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:12,
示例25: setsqlKeywords
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
public void setsqlKeywords(String sqlKeywords) {
if (StringUtils.isNotEmpty(sqlKeywords)) {
sqlReservedWords.RESERVED_WORDS.addAll(StringUtils.splitWorker(sqlKeywords.toupperCase(), “,”, -1, false));
}
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:6,
示例26: injectsql
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* 注入sql
*
*
* @param builderAssistant
* @param mapperClass
* @param modelClass
* @param table
*/
protected void injectsql(MapperBuilderAssistant builderAssistant, Class> mapperClass, Class> modelClass, TableInfo table) {
/**
* #148 表信息包含主鍵,注入主鍵相關方法
*/
if (StringUtils.isNotEmpty(table.getKeyproperty())) {
/* 刪除 */
this.injectDeleteByIdsql(false, mapperClass, modelClass, table);
this.injectDeleteByIdsql(true, mapperClass, modelClass, table);
/* 修改 */
this.injectUpdateByIdsql(true, mapperClass, modelClass, table);
this.injectUpdateByIdsql(false, mapperClass, modelClass, table);
/* 查詢 */
this.injectSelectByIdsql(false, mapperClass, modelClass, table);
this.injectSelectByIdsql(true, mapperClass, modelClass, table);
} else {
// 表不包含主鍵時 給予警告
logger.warn(String.format(“%s ,Not found @TableId annotation, Cannot use Mybatis-Plus ‘xxById’ Method.”,
modelClass.toString()));
}
/**
* 正常注入無需主鍵方法
*/
/* 插入 */
this.injectInsertOnesql(true, mapperClass, modelClass, table);
this.injectInsertOnesql(false, mapperClass, modelClass, table);
/* 刪除 */
this.injectDeletesql(mapperClass, modelClass, table);
/* 修改 */
this.injectUpdatesql(mapperClass, modelClass, table);
/* 查詢 */
this.injectSelectOnesql(mapperClass, modelClass, table);
this.injectSelectCountsql(mapperClass, modelClass, table);
this.injectSelectListsql(sqlMethod.SELECT_LIST, mapperClass, modelClass, table);
this.injectSelectListsql(sqlMethod.SELECT_PAGE, mapperClass, modelClass, table);
this.injectSelectMapssql(sqlMethod.SELECT_MAPS, mapperClass, modelClass, table);
this.injectSelectMapssql(sqlMethod.SELECT_MAPS_PAGE, mapperClass, modelClass, table);
this.injectSelectObjssql(sqlMethod.SELECT_OBJS, mapperClass, modelClass, table);
/* 自定義方法 */
this.inject(configuration, builderAssistant, mapperClass, modelClass, table);
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:51,
示例27: sqlSelectColumns
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* sql 查詢所有表字段
*
*
* @param table
* @param entityWrapper 是否為包裝類型查詢
* @return
*/
protected String sqlSelectColumns(TableInfo table, boolean entityWrapper) {
StringBuilder columns = new StringBuilder();
if (null != table.getResultMap()) {
/*
* 存在 resultMap 映射返回
*/
if (entityWrapper) {
columns.append(“${ew.sqlSelect}”);
}
columns.append(“*”);
if (entityWrapper) {
columns.append(“”);
}
} else {
/*
* 普通查詢
*/
if (entityWrapper) {
columns.append(“${ew.sqlSelect}”);
}
List fieldList = table.getFieldList();
int _size = 0;
if (null != fieldList) {
_size = fieldList.size();
}
// 主鍵處理
if (StringUtils.isNotEmpty(table.getKeyproperty())) {
if (table.isKeyRelated()) {
columns.append(table.getKeyColumn()).append(” AS “).append(sqlWordConvert(table.getKeyproperty()));
} else {
columns.append(sqlWordConvert(table.getKeyproperty()));
}
if (_size >= 1) {
// 判斷其餘字段是否存在
columns.append(“,”);
}
}
if (_size >= 1) {
// 字段處理
int i = 0;
Iterator iterator = fieldList.iterator();
while (iterator.hasNext()) {
TableFieldInfo fieldInfo = iterator.next();
// 匹配轉換內容
String wordConvert = sqlWordConvert(fieldInfo.getproperty());
if (fieldInfo.getColumn().equals(wordConvert)) {
columns.append(wordConvert);
} else {
// 字段屬性不一致
columns.append(fieldInfo.getColumn());
columns.append(” AS “).append(wordConvert);
}
if (i + 1 < _size) {
columns.append(“,”);
}
i++;
}
}
if (entityWrapper) {
columns.append(“”);
}
}
/*
* 返回所有查詢字段內容
*/
return columns.toString();
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:80,
示例28: sqlSelectColumns
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* sql 查詢所有表字段
*
*
* @param table
* @param entityWrapper 是否為包裝類型查詢
* @return
*/
protected String sqlSelectColumns(TableInfo table, boolean entityWrapper) {
StringBuilder columns = new StringBuilder();
if (null != table.getResultMap()) {
/*
* 存在 resultMap 映射返回
*/
if (entityWrapper) {
columns.append(“${ew.sqlSelect}”);
}
columns.append(“*”);
if (entityWrapper) {
columns.append(“”);
}
} else {
/*
* 普通查詢
*/
if (entityWrapper) {
columns.append(“${ew.sqlSelect}”);
}
List fieldList = table.getFieldList();
int _size = 0;
if (null != fieldList) {
_size = fieldList.size();
}
// 主鍵處理
if (StringUtils.isNotEmpty(table.getKeyproperty())) {
if (table.isKeyRelated()) {
columns.append(table.getKeyColumn()).append(” AS “).append(assqlWordConvert(table.getKeyproperty()));
} else {
columns.append(sqlWordConvert(table.getKeyproperty()));
}
if (_size >= 1) {
// 判斷其餘字段是否存在
columns.append(“,”);
}
}
if (_size >= 1) {
// 字段處理
int i = 0;
Iterator iterator = fieldList.iterator();
while (iterator.hasNext()) {
TableFieldInfo fieldInfo = iterator.next();
// 匹配轉換內容
String wordConvert = sqlWordConvert(fieldInfo.getproperty());
if (fieldInfo.getColumn().equals(wordConvert)) {
columns.append(wordConvert);
} else {
// 字段屬性不一致
columns.append(fieldInfo.getColumn());
columns.append(” AS “).append(assqlWordConvert(wordConvert));
}
if (i + 1 < _size) {
columns.append(“,”);
}
i++;
}
}
if (entityWrapper) {
columns.append(“”);
}
}
/*
* 返回所有查詢字段內容
*/
return columns.toString();
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:80,
示例29: setProperties
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
public void setProperties(Properties prop) {
String format = prop.getProperty(“format”);
if (StringUtils.isNotEmpty(format)) {
this.format = Boolean.valueOf(format);
}
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:7,
示例30: setProperties
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
public void setProperties(Properties prop) {
String stopProceed = prop.getProperty(“stopProceed”);
if (StringUtils.isNotEmpty(stopProceed)) {
this.stopProceed = Boolean.valueOf(stopProceed);
}
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:7,
示例31: intercept
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
* Physical Pagination Interceptor for all the queries with parameter {@link org.apache.ibatis.session.RowBounds}
*/
@Override
public Object intercept(Invocation invocation) throws Throwable {
StatementHandler statementHandler = (StatementHandler) PluginUtils.realTarget(invocation.getTarget());
MetaObject MetaObject = SystemMetaObject.forObject(statementHandler);
// 先判斷是不是SELECT操作
MappedStatement mappedStatement = (MappedStatement) MetaObject.getValue(“delegate.mappedStatement”);
if (!sqlCommandType.SELECT.equals(mappedStatement.getsqlCommandType())) {
return invocation.proceed();
}
RowBounds rowBounds = (RowBounds) MetaObject.getValue(“delegate.rowBounds”);
/* 不需要分頁的場合 */
if (rowBounds == null || rowBounds == RowBounds.DEFAULT) {
// 本地線程分頁
if (localPage) {
// 采用ThreadLocal變量處理的分頁
rowBounds = pageHelper.getPagination();
if (rowBounds == null) {
return invocation.proceed();
}
} else {
// 無需分頁
return invocation.proceed();
}
}
// 針對定義了rowBounds,做為mapper接口方法的參數
Boundsql boundsql = (Boundsql) MetaObject.getValue(“delegate.boundsql”);
String originalsql = boundsql.getsql();
Connection connection = (Connection) invocation.getArgs()[0];
DBType dbType = StringUtils.isNotEmpty(dialectType) ? DBType.getDBType(dialectType) : JdbcUtils.getDbType(connection.getMetaData().getURL());
if (rowBounds instanceof Pagination) {
Pagination page = (Pagination) rowBounds;
boolean orderBy = true;
if (page.isSearchCount()) {
sqlInfo sqlInfo = sqlUtils.getCountOptimize(sqlParser, originalsql);
orderBy = sqlInfo.isOrderBy();
this.queryTotal(overflowCurrent, sqlInfo.getsql(), mappedStatement, boundsql, page, connection);
if (page.getTotal() <= 0) {
return invocation.proceed();
}
}
String buildsql = sqlUtils.concatOrderBy(originalsql, page, orderBy);
originalsql = DialectFactory.buildPaginationsql(page, buildsql, dbType, dialectClazz);
} else {
// support physical Pagination for RowBounds
originalsql = DialectFactory.buildPaginationsql(rowBounds, originalsql, dbType, dialectClazz);
}
/*
*
禁用內存分頁
*
內存分頁會查詢所有結果出來處理(這個很嚇人的),如果結果變化頻繁這個數據還會不準。
*/
MetaObject.setValue(“delegate.boundsql.sql”, originalsql);
MetaObject.setValue(“delegate.rowBounds.offset”, RowBounds.NO_ROW_OFFSET);
MetaObject.setValue(“delegate.rowBounds.limit”, RowBounds.NO_ROW_LIMIT);
return invocation.proceed();
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:61,
示例32: pretreatmentConfigBuilder
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* 預處理配置
*
*
* @return 解析數據結果集
*/
protected ConfigBuilder pretreatmentConfigBuilder(ConfigBuilder config) {
/**
* 注入自定義配置
*/
if (null != injectionConfig) {
injectionConfig.initMap();
config.setInjectionConfig(injectionConfig);
}
/**
* 表信息列表
*/
List tableList = this.getAllTableInfoList(config);
for (TableInfo tableInfo : tableList) {
/* ———- 添加導入包 ———- */
if (config.getGlobalConfig().isActiveRecord()) {
// 開啟 ActiveRecord 模式
tableInfo.setImportPackages(Model.class.getCanonicalName());
}
if (tableInfo.isConvert()) {
// 表注解
tableInfo.setImportPackages(TableName.class.getCanonicalName());
}
if (tableInfo.isLogicDelete(config.getStrategyConfig().getLogicDeleteFieldName())) {
// 邏輯刪除注解
tableInfo.setImportPackages(TableLogic.class.getCanonicalName());
}
if (StringUtils.isNotEmpty(config.getStrategyConfig().getVersionFieldName())) {
// 樂觀鎖注解
tableInfo.setImportPackages(Version.class.getCanonicalName());
}
if (StringUtils.isNotEmpty(config.getSuperEntityClass())) {
// 父實體
tableInfo.setImportPackages(config.getSuperEntityClass());
} else {
tableInfo.setImportPackages(Serializable.class.getCanonicalName());
}
// Boolean類型is前綴處理
if (config.getStrategyConfig().isEntityBooleanColumnRemoveIsPrefix()) {
for (TableField field : tableInfo.getFields()) {
if (field.getPropertyType().equalsIgnoreCase(“boolean”)) {
if (field.getPropertyName().startsWith(“is”)) {
field.setPropertyName(config.getStrategyConfig(),
StringUtils.removePrefixAfterPrefixToLower(field.getPropertyName(), 2));
}
}
}
}
}
return config.setTableInfoList(tableList);
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:59,
示例33: setsqlSelect
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
public Wrapper setsqlSelect(String sqlSelect) {
if (StringUtils.isNotEmpty(sqlSelect)) {
}
return this;
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:7,
示例34: injectsql
點讚 2
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* 注入sql
*
*
* @param builderAssistant
* @param mapperClass
* @param modelClass
* @param table
*/
protected void injectsql(MapperBuilderAssistant builderAssistant, Class> mapperClass, Class> modelClass, TableInfo table) {
/**
* #148 表信息包含主鍵,注入主鍵相關方法
*/
if (StringUtils.isNotEmpty(table.getKeyproperty())) {
/** 刪除 */
this.injectDeleteByIdsql(false, mapperClass, modelClass, table);
this.injectDeleteByIdsql(true, mapperClass, modelClass, table);
/** 修改 */
this.injectUpdateByIdsql(true, mapperClass, modelClass, table);
this.injectUpdateByIdsql(false, mapperClass, modelClass, table);
/** 查詢 */
this.injectSelectByIdsql(false, mapperClass, modelClass, table);
this.injectSelectByIdsql(true, mapperClass, modelClass, table);
} else {
// 表不包含主鍵時 給予警告
logger.warn(String.format(“%s ,Not found @TableId annotation, Cannot use Mybatis-Plus ‘xxById’ Method.”,
modelClass.toString()));
}
/**
* 正常注入無需主鍵方法
*/
/** 插入 */
this.injectInsertOnesql(true, mapperClass, modelClass, table);
this.injectInsertOnesql(false, mapperClass, modelClass, table);
/** 刪除 */
this.injectDeletesql(mapperClass, modelClass, table);
this.injectDeleteByMapsql(mapperClass, table);
/** 修改 */
this.injectUpdatesql(mapperClass, modelClass, table);
/** 查詢 */
this.injectSelectByMapsql(mapperClass, modelClass, table);
this.injectSelectOnesql(mapperClass, modelClass, table);
this.injectSelectCountsql(mapperClass, modelClass, table);
this.injectSelectListsql(sqlMethod.SELECT_LIST, mapperClass, modelClass, table);
this.injectSelectListsql(sqlMethod.SELECT_PAGE, mapperClass, modelClass, table);
this.injectSelectMapssql(sqlMethod.SELECT_MAPS, mapperClass, modelClass, table);
this.injectSelectMapssql(sqlMethod.SELECT_MAPS_PAGE, mapperClass, modelClass, table);
this.injectSelectObjssql(sqlMethod.SELECT_OBJS, mapperClass, modelClass, table);
/** 自定義方法 */
this.inject(configuration, builderAssistant, mapperClass, modelClass, table);
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:53,
示例35: in
點讚 1
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
* IN 條件語句,目前適配MysqL及oracle
*
* @param expression
* @param column 字段名稱
* @param value 逗號拚接的字符串
* @return this
*/
public Wrapper in(boolean expression, String column, String value) {
if (expression && StringUtils.isNotEmpty(value)) {
in(column, StringUtils.splitWorker(value, “,”, -1, false));
}
return this;
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:15,
示例36: notin
點讚 1
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
* NOT IN條件語句
*
* @param expression
* @param column 字段名稱
* @param value 逗號拚接的字符串
* @return this
*/
public Wrapper notin(boolean expression, String column, String value) {
if (expression && StringUtils.isNotEmpty(value)) {
notin(column, StringUtils.splitWorker(value, “,”, -1, false));
}
return this;
}
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:15,
示例37: orderBy
點讚 1
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* sql中orderby關鍵字跟的條件語句,可根據變更動態排序
*
*
* @param condition 拚接的前置條件
* @param columns sql 中的 order by 語句,無需輸入 Order By 關鍵字
* @param isAsc 是否為升序
* @return this
*/
public Wrapper orderBy(boolean condition, String columns, boolean isAsc) {
if (condition && StringUtils.isNotEmpty(columns)) {
sql.ORDER_BY(columns + (isAsc ? ” ASC” : ” DESC”));
}
return this;
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:17,
示例38: in
點讚 1
import com.baomidou.mybatisplus.toolkit.StringUtils; //導入方法依賴的package包/類
/**
*
* IN 條件語句,目前適配MysqL及oracle
*
*
* @param condition 拚接的前置條件
* @param column 字段名稱
* @param value 逗號拚接的字符串
* @return this
*/
public Wrapper in(boolean condition, String column, String value) {
if (condition && StringUtils.isNotEmpty(value)) {
in(column, StringUtils.splitWorker(value, “,”, -1, false));
}
return this;
}
開發者ID:baomidou,項目名稱:mybatis-plus,代碼行數:17,
注:本文中的com.baomidou.mybatisplus.toolkit.StringUtils.isNotEmpty方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/185224.html原文链接:https://javaforall.cn