com.mybatiseasy.core.sqlbuilder.Fun Maven / Gradle / Ivy
/*
* Copyright (c) 2023, 杭州坦信科技有限公司 (https://www.mybatis-easy.com).
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.mybatiseasy.core.sqlbuilder;
import com.mybatiseasy.core.base.Column;
public class Fun {
/**
* 格式化sql字符串
* @param template 模板
* @param columns 字段
* @return String
*/
public static String template(String template, Column...columns){
for(int i=0;i< columns.length;i++){
Column column = columns[i];
template = template.replaceAll("\\#\\{"+i+"\\}", column.getFullColumn());
}
return template;
}
public static String method(String methodName, Column column){
return methodName + "("+ column.getFullColumn() +")";
}
public static String max(Column column){
return method("max", column);
}
public static String min(Column column){
return method("min", column);
}
public static String avg(Column column){
return method("avg", column);
}
public static String sum(Column column){
return method("sum", column);
}
public static String count(Column column){
return method("count", column);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy