【7.6.0】更新BaseRequest中获取自定义排序字段的sql拼接

dev-7.6.0-hang
fengshuonan 2023-05-30 16:33:32 +08:00
parent b4e6aac282
commit 335d1821e8
1 changed files with 26 additions and 0 deletions

View File

@ -24,7 +24,10 @@
*/
package cn.stylefeng.roses.kernel.rule.pojo.request;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import cn.stylefeng.roses.kernel.rule.util.SqlInjectionDetector;
import lombok.Data;
import java.io.Serializable;
@ -165,4 +168,27 @@ public class BaseRequest implements Serializable {
public @interface batchDelete {
}
/**
* sql
* <p>
* orderBysortBysql
*
* @author fengshuonan
* @since 2023/5/30 16:29
*/
public String getOrderByLastSql() {
if (ObjectUtil.isEmpty(this.orderBy) || ObjectUtil.isEmpty(this.sortBy)) {
return StrUtil.EMPTY;
}
// 检测这俩参数有没有注入风险
if (SqlInjectionDetector.hasSqlInjection(this.orderBy) || SqlInjectionDetector.hasSqlInjection(this.sortBy)) {
return StrUtil.EMPTY;
}
// 进行order by语句的拼接
return " order by " + this.orderBy + " " + this.sortBy + " ";
}
}