All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.wz2cool.dynamic.mybatis.mapper.helper.GroupedQuerySqlHelper Maven / Gradle / Ivy

There is a newer version: 3.2.32
Show newest version
package com.github.wz2cool.dynamic.mybatis.mapper.helper;

import com.github.wz2cool.dynamic.mybatis.mapper.constant.MapperConstants;

/**
 * @author Frank
 */
public class GroupedQuerySqlHelper {
    private GroupedQuerySqlHelper() {
        throw new UnsupportedOperationException();
    }

    public static String getBindFilterParams(boolean isMapUnderscoreToCamelCase) {
        StringBuilder sql = new StringBuilder();
        sql.append("");
        return sql.toString();
    }

    public static String getSelectColumnsClause() {
        return String.format(" ${%s.%s} ", MapperConstants.GROUPED_QUERY_PARAMS, MapperConstants.SELECT_COLUMNS_EXPRESSION);
    }

    public static String getWhereClause() {
        String newExpression = String.format("%s.%s", MapperConstants.GROUPED_QUERY_PARAMS, MapperConstants.WHERE_EXPRESSION);
        return String.format("WHERE ${%s}",
                newExpression, newExpression, newExpression);
    }

    public static String getGroupByClause() {
        String newExpression = String.format("%s.%s", MapperConstants.GROUPED_QUERY_PARAMS, MapperConstants.GROUP_COLUMNS_EXPRESSION);
        return String.format("GROUP BY ${%s}",
                newExpression, newExpression, newExpression);
    }

    public static String getHavingClause() {
        String newExpression = String.format("%s.%s", MapperConstants.GROUPED_QUERY_PARAMS, MapperConstants.HAVING_EXPRESSION);
        return String.format("HAVING ${%s}",
                newExpression, newExpression, newExpression);
    }

    public static String getSortClause() {
        String newExpression = String.format("%s.%s", MapperConstants.GROUPED_QUERY_PARAMS, MapperConstants.SORT_EXPRESSION);
        return String.format("ORDER BY ${%s}",
                newExpression, newExpression, newExpression);
    }

    public static String getSelectMax() {
        return String.format("SELECT MAX(${%s})", MapperConstants.COLUMN);
    }

    public static String getSelectMin() {
        return String.format("SELECT MIN(${%s})", MapperConstants.COLUMN);
    }

    public static String getSelectSum() {
        return String.format("SELECT SUM(${%s})", MapperConstants.COLUMN);
    }

    public static String getSelectAvg() {
        return String.format("SELECT AVG(${%s})", MapperConstants.COLUMN);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy