com.mybaits.jpa.util.SqlUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mybatis-jpa Show documentation
Show all versions of mybatis-jpa Show documentation
Mybaits JPA: a convenient development tool for mybatis puls
package com.mybaits.jpa.util;
import com.mybaits.jpa.jpaEnum.KeyWord;
import com.mybaits.jpa.sql.split.ISqlMethodSplit;
import com.mybaits.jpa.sql.split.impl.*;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Administrator on 2019/12/20 0020.
*/
public class SqlUtils {
/**
* 首字母大写
* @return
*/
public static String firstCapitalization(String info){
StringBuffer sb=new StringBuffer(info);
if(info!=null&&info!=""&&info.length()>0){
String charInfo=sb.substring(0,1);
sb.replace(0,1,charInfo.toUpperCase());
return sb.toString();
}
return info;
}
/**
* 驼峰命名转换为下划线命名
* @param para
* @return
*/
public static String HumpToUnderline(String para){
StringBuilder sb=new StringBuilder(para);
int temp=0;//定位
if (!para.contains("_")) {
for(int i=0;i getKeyword(String mehtod){
ISqlMethodSplit iSqlMethodSplit=null;
List keyWords=new ArrayList<>();
keyWords.add(mehtod);
if(mehtod.indexOf(KeyWord.And.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitAnd();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.NotLike.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitNotLike();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.Like.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitLike();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.IsNotNull.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitIsNotNull();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.IsNull.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitIsNull();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.NotIn.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitNotIn();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.In.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitIn();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.OrderBy.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitOrderBy();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.Or.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitOr();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.After.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitAfter();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.Before.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitBefore();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.LessThan.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitLessThan();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.GreaterThan.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitGreaterThan();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.Asc.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitAsc();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
if(mehtod.indexOf(KeyWord.Desc.getValue())!=-1){
iSqlMethodSplit=new SqlMethodSplitDesc();
keyWords=iSqlMethodSplit.sqlMethodSplit(keyWords);
}
return keyWords;
}
}